C++ program. You have been contracted by a small-town bank that would like for y
ID: 640832 • Letter: C
Question
C++ program. You have been contracted by a small-town bank that would like for you to implement a custom software system for managing bank accounts and transactions. As a prototype you decided to show them a menu driven example. Your menu driven example has the following menu:
Bank Login Menu
-------------------------
A) Log into an account
B) Open a new account
C) Show all accounts
D) Exit System
After a user has successfully logged in, then following menu should show:
Bank Menu
------------------------------------
A) Show account balance
B) Make a deposit
C) Make a withdrawal
D) Write a Check
E) Show all transactions
F) Logout of an account
If the user logs out of the system, then the login menu should be shown again.
Your software is designed using at least three classes: Account, Transaction, Deposit(inherits from Transaction), Withdrawal(inherits from Transaction), and Check(inherits from Transaction).
The Account class represents a single bank account and keeps track of at least this data:
? First and Last Name of the account holder
? Account number (9 digits, starting with the number 1)
? Account password
? Account balance
? Number of Transactions
? A list of all transactions
The Account class has at least the following responsibilities:
? Process withdrawals, checks, and deposits
? Manage all account data
? Validate login password
? Access to a single transaction by transaction number
? Enable proper access to data
The Transaction class represents a single transactions and keeps track of at least this data:
? Transaction ID
? Transaction Amount
The Transaction class has at least the following responsibilities:
? Manage all data for a transaction
? Enable proper access to data
Remember that the transactions for checks, deposits, and withdrawals inherit from the transaction class. You must decide whether you want this to be a base class or abstract base class.
Your bank account program will be based on performing the activities of the menu. You will use an external file to keep track of the bank account numbers and their passwords. This way bank accounts can be created and then logged into later. In addition, no menu operations should work unless an account has been logged into and is validated. This file should be called allaccounts.txt and is formatted as follows:
<Account Number> <First Name> <Last Name> <Password> <Balance>
Each line of the file contains one bank customer with the above information. This information must be saved between uses of the program. The file should be read into into an array of objects when the program starts, and when the program is being exited (option D) the program should then write the data from the array of objects back to the file. This will overwrite the file entirely. Do not have a program that is always updating and reading the file with every change. Changes that occur during the program execution should only be effected in the array of objects. You should not be using the random access file techniques found in Chapter 12.
Transactions are maintained on a session-by-session basis. This means that once you log in, each transaction you perform is tracked for that session. So if you were to make a deposit, write two checks, and make a withdrawal then you should use show transactions to show you those four transactions. However, once you log out the transactions are removed.
Logging out of an account should not exit the program. It only means that a successful login to some account must be made before more transactions can occur.
Notice that the requirements are minimal requirements. This is because the bank management had some basic requirements. But as a software developer, you may see the need to add data and/or features.
Explanation / Answer
#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;
}
void display_accinfo()
{
cout<<" Customer Name :- "<<cust_name;
cout<<" Account Number :- "<<acc_no;
cout<<" Account Type :- "<<acc_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.