Professional Documents
Culture Documents
ASSIGNMENT #2
Structures
Danyal Khan
160401030
EE-15-A
9th April 2019
Define a structure definition for a bank account with the following data members:
Customer Name, Bank Name, Branch of the bank, Balance
Add the following member functions to the structure:
Function components:
Credit Process (To credit the balance with some amount)
Debit Process (To debit the balance with some amount)
Balance Process (to display balance)
Create Account(to get name, bank name, branch name, amount to be deposited)
Account information (to display name, bank, branch, balance)
Use a do while loop to continuously running the program until user select option 6
which then stops execution of the program.
Data should be kept on file so that data it is readily be available for any transaction in
future.
#include<iostream>
#include<string.h>
#include<conio.h>
#include<fstream>
struct bank{
string customer,bank,branch;
float balance;
void account_create(string,string,string,float)
{
cout<<"Enter Customer name : ";
cin.ignore();
getline(cin,customer);
getline(cin,bank);
getline(cin,branch);
cin>>balance;
void creditprocess()
int i;
cin>>i;
balance=balance+i;
void debitprocess()
int i;
cin>>i;
if(i>balance)
getch();
else
balance=balance-i;
void inquiry()
{
void accountinfo()
cout<<"Balance : "<<balance;
};
int main()
bank x[100];
int k;
int y=0;
int z;
do{
system("CLS");
cout<<"Enter 6 to exit"<<endl;
cin>>z;
switch(z)
case 1:
x[y].account_create(x[y].customer,x[y].bank,x[y].branch,x[y].balance);
y++;
break;
case 2:
cin>>k;
if(k<=y)
x[k-1].creditprocess();
else
getch();
break;
case 3:
cin>>k;
if(k<=y)
x[k-1].debitprocess();
else
getch();
break;
case 4:
cin>>k;
if(k<=y)
x[k-1].inquiry();
else
getch();
break;
case 5:
cin>>k;
if(k<=y)
x[k-1].accountinfo();
else
getch();
break;
case 6:
ofstream file;
file.open("danyal.txt");
for(int i=0;i<y;i++)
return 0;
while (1);