Using Switch statement, write a program that displays the following menu for the bank operations available to take services from the customer:
D= Deposit, W= Withdraw T= Transfer
The program inputs the type of service and amount. It finally displays the amount to be transfer/deposit/transfer after applying charges, total remaining balance of customer according to the following criteria:
Deposit = 0.5% charges of deposited amount
Withdraw = 1.5% charges of withdraw amount
Transfer = 2.5% charges of transfer amount
#include<iostream>
#include<string>
using namespace std;
int main()
{
char ch=' ';
double amount;
double balance=0;
double charges;
while(ch!='E' && ch!='e'){
cout<<"D= Deposit, W= Withdraw T= Transfer E= Exit: ";
cin>>ch;
switch(ch){
case 'D':
case 'd':{
//Deposit = 0.5% charges of deposited amount
cout<<"Enter amount to deposit: ";
cin>>amount;
charges=amount*(0.5/100.0);
balance+=(amount-charges);
cout<<"Charges: "<<charges<<"\n";
cout<<"Balance: "<<balance<<"\n";
}
break;
case 'W':
case 'w':{
//Withdraw = 1.5% charges of withdraw amount
cout<<"Enter amount to withdraw: ";
cin>>amount;
charges=amount*(1.5/100.0);
balance-=(amount+charges);
cout<<"Charges: "<<charges<<"\n";
cout<<"Balance: "<<balance<<"\n";
}
break;
case 'T':
case 't':{
//Transfer = 2.5% charges of transfer amount
cout<<"Enter amount to transfer: ";
cin>>amount;
charges=amount*(2.5/100.0);
balance-=(amount+charges);
cout<<"Charges: "<<charges<<"\n";
cout<<"Balance: "<<balance<<"\n";
}
break;
case 'E':
case 'e':{
//exit
}
break;
default:{
}
break;
}
}
return 0;
}
Comments
Leave a comment