You have been asked to write a program for a bank. Your main entity is the bank
ID: 3835308 • Letter: Y
Question
You have been asked to write a program for a bank. Your main entity is the bank account which has the following characteristics:
It holds the customer information (national ID, name, address, email, mobile number…etc)
It holds the current balance.
For simplicity, we will not record the previous transactions.
The user can perform 7 operations:
Create a new account
Deposit: add an amount of money to the balance.
Withdrawal: withdraw an amount of money from the balance if there is sufficient amount in the current balance.
Check balance: print the current balance on the screen.
Get a new loan:
The customer can have also a loan so the system should keep track of the following:
Does the customer have a loan?
How much is the loan?
The loan period in years (e.g. rate = 5 years). What is the interest rate on this loan?
o Interest = loan * (rate/100)
How much the customer should pay in total and monthly which we will calculate as follow:
o Total payable amount = loan + interest
o The monthly payment = Total payable amount / (number of years * 12)
The remaining amount to be paid, which should be updated with each new payment.
When a customer gets a loan, the loan amount should be added to his current balance.
For simplicity we will not keep track of the payments dates and will not examine to see if a customer is late on his payments.
Also for simplicity the customer can get a new loan if he does not have any remaining balance to be paid from a previous loan.
Check loan: print the status of the current loan (if exist) on the screen
Pay for a loan: the customer can pay only the monthly amount due.
Finally, you should create a Bank class that contains the main method with the following:
It must print a selection screen were the user can choose the operation he/she wants to perform:
Create a new account.
Deposit an amount on an existing account.
Withdrawal an amount from an existing account.
Check the current balance of an existing account.
Get a new loan on an existing account.
Check an existing loan status (the amount, the remaining balance, the monthly payments … etc).
Pay for the monthly payment for an existing loan.
List the names and the account numbers for all customers of the bank in alphabetical order.
When a user choses the operation he would like to perform he will be asked for the appropriate information (such as the account number)
For example the main screen should look something like this:
The user must be able to create several accounts at one session and they must be stored in an ArrayList.
Each class (apart from the main class) must override the methods toString and equals from class Object.
In your solution, you must use at least 3 classes and you should utilize (use) the following concepts:
Inheritance.
Interface or abstract class.
Your submitted program must be working correctly and satisfy all these requirements in order to receive a good mark.
Explanation / Answer
The desired program is given below:
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
class bank_Account {
int account_num;
static reset;
float account_balance, account_amount, shorta;
public:
void account_deposit();
void account_withdraw();
void chkaccount_balance();
int menu();
};
int bank_Account::reset=0;
void bank_Account::account_deposit() {
cout<<" Enter Account Number:";
cin>>account_num;
if(account_num==1001)
{
cout<<" Enter Amount to Deposit:";
cin>>account_amount;
account_balance=account_balance+account_amount;
cout<<" Message: You have successfully deposit Rs."<<account_amount<<" in account. Your Current Balance :"<<account_balance<<" ";
reset++;
}
else
{
cout<<"Invalid account number";
}
}
void bank_Account::account_withdraw() {
cout<<"Enter Account Number:";
cin>>account_num;
if(account_num==1001)
{
cout<<"Enter Amount to Withdraw:";
cin>>account_amount;
if(account_amount>account_balance)
{
shorta=account_amount-account_balance;
cout<<" You cannot withdraw Rs."<<account_amount<<" as account_balance is Rs."<<account_balance<<" You are short of rupee."<<shorta;
}
else
{
account_balance=account_balance-account_amount;
cout<<"You Withdrawn Rupee"<<account_amount<<" Successfully Your account balance: "<<account_balance<<" ";
}
}
else
{
cout<<"Invalid account number";
}
}
void bank_Account::chkaccount_balance() {
cout<<"Enter Account Number:";
cin>>account_num;
if(reset==0)
{
account_balance=0;
}
if(account_num==1001)
{
cout<<"Account balance is rupee"<<account_balance<<" ";
}
else
{
cout<<"account not exist!!";
}
}
void main()
{
bank_Account acc_object;
int ch;
clrscr();
do {
cout<<" 1.Account Deposit 2.Account Withdraw 3.Account Balance Enquiry 4.Account Exit ";
ch=acc_object.menu();
switch(ch)
{
case 1:acc_object.account_deposit();
break;
case 2:acc_object.account_withdraw();
break;
case 3:acc_object.chkaccount_balance();
break;
case 4: exit(1);
default:cout<<"Invalid Option Selected!!";
}
}while(1);
}
int bank_Account::menu()
{
int ch;
cout<<" Enter the Choice:";
cin>>ch;
return ch;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.