Write program to input for each customer : account number, the beginning balance
ID: 3622595 • Letter: W
Question
Write program to input for each customer : account number, the beginning balance.The program should contain three functions:
1) Deposit ? Deposit an amount of money.
2) Withdraw ?Withdraw an amount of money.
3) Print ? Print all information after updates .
It should calculate and print the new balance according to selected function:
Your program sholud have 2 menus:
First Menu:
*************** Menu ***************
1- New customer
2- Exit
***********************************
Sub menu:
*************** Menu ***************
3- Deposit an amount of money
4- Withdraw an amount of money
5- Display all information with new balance
6- Exit
***********************************
In your program :
• The inner loop continues till user selects Exit ,then the user will back to the first menu.
Explanation / Answer
please rate - thanks
#include <iostream>
using namespace std;
void PrintMenu2()
{cout<<"*************** Menu *************** ";
cout<<"3- Deposit an amount of money ";
cout<<"4- Withdraw an amount of money ";
cout<<"5- Display all information with new balance ";
cout<<"6- Exit ";
}
void PrintMenu1()
{cout<<"*************** Menu *************** ";
cout<<"1- New customer ";
cout<<"2- Exit ";
}
int main()
{int choice,selection;
double balance, amount;
do
{PrintMenu1();
cin>>selection;
if(selection==1)
{balance=0;
do{
PrintMenu2();
cin>>choice;
switch(choice)
{
case 4:cout<<"Enter amount: $";
cin>>amount;
if(amount>balance)
cout<<"You do not have enough money to make that withdrawal ";
else
balance-=amount;
break;
case 3:cout<<"Enter amount: $";
cin>>amount;
balance+=amount;
break;
case 5:cout<<"Current Balance: $"<<balance<<endl<<endl;
break;
case 6:cout<<"Thanks for using our ATM! ";
break;
default:cout<<choice<<"Illegal entry ";
}
}while (choice!=6);
}else if(selection<1||selection>2)
cout<<choice<<"Illegal entry ";
}while(selection!=2);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.