CHECKBOOK PROGRAM
I have almost everything that i want to work, working right, except I have no idea how to accumulate the value of the Balance after a Deposit, Withdrawal, etc.. How do I put that in main? or does it go in main? Any Suggestions?
Code:
#include <iomanip.h>
#include <stdlib.h>
float Dep(float Bal, float Amount)
{ return (Bal+Amount);}
float Check(float Bal, float Amount)
{ return (Bal-Amount);}
float Charge(float Bal, float Amount)
{ return (Bal-Amount);}
float Withdraw(float Bal, float Amount)
{ return (Bal-Amount);}
main()
{ float Bal, Amount; char Comm;
cout<<"\n BALANCING CHECKBOOK PROGRAM ";
cout<<"\n --------------------------- ";
cout<<"\n\n My Account ";
cout<<"\n Enter Starting Balance : "; cin>>Bal;
cout<<"\n Command Options: "
<<"\n d- deposit"
<<"\n c- check "
<<"\n s- service charge "
<<"\n w- withdrawal "
<<"\n x- exit "<<endl;
cout<<"\n Enter command: "; cin>>Comm;
cout<<"\n Enter amount in dollars and cents: "; cin>>Amount;
while(Comm != 'x')
{ cout<<"\n Enter another command: "; cin>>Comm;
if(Comm == 'd')
{Dep(Bal, Amount);cout<<"\n Enter amount in dollars and cents: "; cin>>Amount;}
else if(Comm == 'c')
{Check(Bal,Amount);cout<<"\n Enter amount in dollars and cents: "; cin>>Amount;}
else if(Comm == 's')
{Charge(Bal,Amount);cout<<"\n Enter amount in dollars and cents: "; cin>>Amount;}
else if(Comm == 'w')
{Withdraw(Bal,Amount);cout<<"\n Enter amount in dollars and cents: "; cin>>Amount;}
else if(Comm == 'x')
{break;}
}
cout<<"\n Your New Balance is: $"<<Bal;
system("PAUSE");
return 0;
}
Thanks in advance