Balance Inquiry: when this option is chosen, just print a simple \"receipt\": In
ID: 3750707 • Letter: B
Question
Balance Inquiry: when this option is chosen, just print a simple "receipt": Inc. I should line up with the dollar sign below Assume the max balance is 99999.99 5 digits before, 2 after the point. Account: BA-3456-78 Balance: 275.50 Deposit: when this option is chosen, ask for the deposit amount (assume they will enter a float) and print a receipt Enter deposit amount: 100.00 Inc. I All should line up as shown. All amounts assumed to be 99999.99 or less Account: BA-3456-78 Prev Bal: 275.50 Deposit: 100.00 New Bal: 375.50 Withdrawal: when this option is chosen, ask for the withdrawal amount (assume they will enter a float) Repeat the question as long as the amount entered is greater than the current balance. Then print a receipt Enter withdrawal amount: 500.00 Insufficient Funds. Current Balance is $ 275.50 Enter withdrawal amount: 100.00 All should line up as shown. All amounts assumed to be 99999.99 or less. Account: BA-3456-78 Prev Bal: $ 275.50 Withdrawn: $ 100.00 New Bal: S 175.50Explanation / Answer
Program
#include<iostream>
#include <cstdlib>
using namespace std;
int main()
{
string account_no;
double balance;
double withdraw, deposit;
char option;
cout<<" ";
cout<<"+--------------------------+"<<endl;
cout<<"| KOTAK BANK,Inc | ";
cout<<"+--------------------------+"<<endl;
cout<<" ";
while(true)
{
cout <<" Enter account number:";
getline(cin,account_no);
if(account_no!="shutdown")
{
cout <<" Enter account balance:";
cin>>balance;
cout<<"Choose a Transaction: ";
cout<<" ";
cout <<"[B] Balance Enquiry "
<<"[D] Deposit "
<<"[W] Withdrawal "
<<" "
<<"Enter Option:";
cin>>option;
switch(option)
{
case 'B':
cout<<" ";
cout<<"+--------------------------+"<<endl;
cout<<"| KOTAK BANK,Inc | ";
cout<<"+--------------------------+"<<endl;
cout<<" ";
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout<<" Account : "<<account_no<<endl;
cout<<" Balance : $"<<balance<<endl;
break;
case 'W':
cout<<"Enter withdrawal amount: $";
cin>>withdraw;
while(balance<withdraw)
{
cout<<" Insufficient balance!!!";
cout<<" Current Balance : $"<<balance<<endl;
cout<<" Enter withdrawal amount: $";
cin>>withdraw;
}
cout<<" ";
cout<<"+--------------------------+"<<endl;
cout<<"| KOTAK BANK,Inc | ";
cout<<"+--------------------------+"<<endl;
cout<<" ";
cout<<" Account : "<<account_no<<endl;
cout<<" Previous Balance : $"<<balance<<endl;
balance = balance - withdraw;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout<<" Withdrawn :$"<<withdraw<<endl;
cout<<" New balance : $"<<balance<<endl;
break;
case 'D':
cout<<" Enter deposit amount: $";
cin>>deposit;
cout<<" ";
cout<<"+--------------------------+"<<endl;
cout<<"| KOTAK BANK,Inc | ";
cout<<"+--------------------------+"<<endl;
cout<<" ";
cout<<" Account : "<<account_no<<endl;
cout<<" Previous Balance : $"<<balance<<endl;
balance = balance + deposit;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout<<" Deposit : $"<<deposit<<endl;
cout<<" New balance : $"<<balance<<endl;
break;
default:
cout<<" That is an invalid option ";
}
}
else
{
cout<<" Shutting down...Bye!"<<endl;
system("pause");
return 0;
}
getline(cin,account_no);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.