You have been hired as a programmer by a major bank. Your first project is a sma
ID: 3694658 • Letter: Y
Question
You have been hired as a programmer by a major bank. Your first project is a small banking transaction system. Each account consists of a number and a balance. The user of the program (the teller) can create a new account, as well as perform deposits, withdrawals, and balance inquiries.
Initially, the account information of existing customers is to be read into a pair of parallel arrays--one for account numbers, the other for balances.
The bank can handle up to MAX_NUM accounts. Use the following function to read in the data values:
int read_accts(int acctnum_array[], double balance_array[], int max_accts);
This function fills up the account number and balance arrays (up to max_accts) and returns the actual number of accounts read in (later referred to as num_accts).
After initialization, print the initial database of accounts and balances. Use function print_accts() described below.
The program then allows the user to select from the following menu of transactions:
Select one of the following:
W - Withdrawal
D - Deposit
N - New account
B - Balance
Q – Quit
X – Delete Account – Extra Credit
Use the following function to produce the menu:
void menu();
This function only displays the menu. The main program then prompts the user for a selection.
You should verify that the user has typed in a valid selection (otherwise print out an error message and repeat the prompt). Once the user has entered a selection, one of the following functions should be called to perform the specific transaction.
At the end, before the user quits, the program prints the contents of the account arrays.
int findacct(int acctnum_array[], int num_accts, int account);
This function returns the index of account in account_array if the account exists, and -1 if it doesn't. It is called by all the remaining functions.
void withdrawal(int acctnum_array[], double balance_array[], int num_accts);
This function prompts the user for the account number. If the account does not exist, it prints an error message. Otherwise, it asks the user for the amount of the withdrawal. If the account does not contain sufficient funds, an it prints an error message and does not perform the transaction.
void deposit(int acctnum_array[], double balance_array[], int num_accts);
This function prompts the user for the account number. If the account does not exist, it prints an error message. Otherwise, it asks the user for the amount of the deposit.
int new_acct(int acctnum_array[], double balance_array[], int num_accts);
This function prompts the user for a new account number. If the account already exists, it prints an error message. Otherwise, it adds the account to the account array with an initial balance of 0. It returns the new number of accounts.
void balance(int acctnum_array[], double balance_array[], int num_accts);
This function prompts the user for an account number. If the account does not exist, it prints an error message. Otherwise, it prints the account balance.
void print_accts(int acctnum_array[], double balance_array[], int num_accts);
This function prints all customer information--account number and balance.
Explanation / Answer
Solution:please follow these coding as shown in below..
#include <iostream.h>
#include <conio.h>
class account
{
char cust_name[20];
int acc_no;
char acc_type[20];
public:
void get_accinfo()
{
cout<<" Enter Customer Name :- ";
cin>>cust_name;
cout<<"Enter Account Number :- ";
cin>>acc_no;
cout<<"Enter Account Type :- ";
cin>>acc_type;
cout<<"Enter NewAccount Type :- ";
cin>>newacc_type;
}
void display_accinfo()
{
cout<<" Customer Name :- "<<cust_name;
cout<<" Account Number :- "<<acc_no;
cout<<" Account Type :- "<<acc_type;
cout<<” NewAccount Type:- "<< newacc_type;
}
};
class cur_acct : public account
{
staticfloat balance;
public:
void disp_currbal()
{
cout<<" Balance :- "<<balance;
}
void deposit_currbal()
{
float deposit;
cout<<" Enter amount to Deposit :- ";
cin>>deposit;
balance = balance + deposit;
}
void withdraw_currbal()
{
float penalty,withdraw;
cout<<" Balance :- "<<balance;
cout<<" Enter amount to be withdraw :-";
cin>>withdraw;
balance=balance-withdraw;
if(balance < 500)
{
penalty=(500-balance)/10;
balance=balance-penalty;
cout<<" Balance after deducting penalty : "<<balance;
}
elseif(withdraw > balance)
{
cout<<" You have to take permission for Bank Overdraft Facility ";
balance=balance+withdraw;
}
else
cout<<" After Withdrawl your Balance revels : "<<balance;
}
};
class sav_acct : public account
{
staticfloat savbal;
public:
void disp_savbal()
{
cout<<" Balance :- "<<savbal;
}
void deposit_savbal()
{
float deposit,interest;
cout<<" Enter amount to Deposit :- ";
cin>>deposit;
savbal = savbal + deposit;
interest=(savbal*2)/100;
savbal=savbal+interest;
}
void withdraw_savbal()
{
float withdraw;
cout<<" Balance :- "<<savbal;
cout<<" Enter amount to be withdraw :-";
cin>>withdraw;
savbal=savbal-withdraw;
if(withdraw > savbal)
{
cout<<" You have to take permission for Bank Overdraft Facility ";
savbal=savbal+withdraw;
}
else
cout<<" After Withdrawl your Balance revels : "<<savbal;
}
};
float cur_acct :: balance;
float sav_acct :: savbal;
void main()
{
clrscr();
cur_acct c1;
sav_acct s1;
cout<<" Enter S for saving customer and C for current a/c customer ";
char type;
cin>>type;
int choice;
if(type=='s' || type=='S')
{
s1.get_accinfo();
while(1)
{
clrscr();
cout<<" Choose Your Choice ";
cout<<"1) Deposit ";
cout<<"2) Withdraw ";
cout<<"3) Display Balance ";
cout<<"4) Display with full Details ";
cout<<"5) Exit ";
cout<<"6) Choose Your choice:-";
cin>>choice;
switch(choice)
{
case 1 : s1.deposit_savbal();
getch();
break;
case 2 : s1.withdraw_savbal();
getch();
break;
case 3 : s1.disp_savbal();
getch();
break;
case 4 : s1.display_accinfo();
s1.disp_savbal();
getch();
break;
case 5 : goto end;
default: cout<<" Entered choice is invalid,"TRY AGAIN"";
}
}
}
else
{
{
c1.get_accinfo();
while(1)
{
cout<<" Choose Your Choice ";
cout<<"1) Deposit ";
cout<<"2) Withdraw ";
cout<<"3) Display Balance ";
cout<<"4) Display with full Details ";
cout<<"5) Exit ";
cout<<"6) Choose Your choice:-";
cin>>choice;
switch(choice)
{
case 1 : c1.deposit_currbal();
getch();
break;
case 2 : c1.withdraw_currbal();
getch();
break;
case 3 : c1.disp_currbal();
getch();
break;
case 4 : c1.display_accinfo();
c1.disp_currbal();
getch();
break;
case 5 : goto end;
default: cout<<" Entered choice is invalid,"TRY AGAIN"";
}
}
}
end:
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.