#include<iostream>
#include<cmath>
usingnamespace std;
int inputoption();
int inputoption()
{
char option;
cout<<"Your opening balance is RM1000.00"<<endl;
cout<<"Enter any one of the following options: "<<endl;
cout<<"0.\tQuit"<<endl;
cout<<"1.\tDeposit"<<endl;
cout<<"2.\tWithdrawal"<<endl;
cout<<"3.\tBalance"<<endl;
cout<<"Your option: ";
do
{
cin>>option;
if(option!='0' && option!='1' && option!='2' && option!='3')
{
cout<<"Invalid option." <<endl;
cout<<"Pleae enter again." <<endl;
}
}
while(!(option>='0' && option<='3'));
return option;
}
int main()
{
doubleconst opb=1000.00;
double cb=0;
double amount;
int userchoice;
userchoice=inputoption();
do
{
if (userchoice=='0')
{
break;
}
elseif(userchoice=='1')
{
cout<<"Amount to Deposits: RM ";
cin>>amount;
cb=opb+amount;
}
elseif(userchoice=='2')
{
cout<<"Amount to Withdraw: RM ";
cin>>amount;
cb=opb-amount;
while(cb<=10.00)
{
cout<<"Sorry, a minumum balance of RM10.00 is required."<<endl;
cout<<"Please enter a new amount or 0 to quit."<<endl;
cout<<"Amoun to Withdraw: RM ";
cin>>amount;
cb=opb-amount;
}
}
elseif(userchoice=='3')
{
cout<<"Your current balance is RM "<<cb<<endl;
}
cout<<"Your current balance is RM "<<cb<<endl;
}while(true);
system("pause");
return 0;
}