I am having a hard time keeping the updated balances, can someone please help me?
this is are my functions in a class called "functions"
and here is my main snippet
void DepositAmt(double *dep_amount,double *cur_bal)
*dep_amount = *dep_amount + *cur_bal;
void WithdrawalAmt(double *wdl_amount,double *cur_bal)
*wdl_amount = *cur_bal - *wdl_amount;
void PrintStatement(Account acc)
void getFinalBalance(double *cur_bal, double *dep_amount, double *wdl_amount)
*cur_bal = *cur_bal + *dep_amount - (wdl_amount;
my problem is that in the end, when I want to display the total deposited and the current balance, it only displays the last amount that I deposited and current balance at zero.
if (choice == 1)
numtrans = numtrans + 1;
cout<<"Please enter the amount you would like to deposit"<<endl;
cout<<"you have deposited : "<<dep_amount<<endl;
cout<<"you have withdrew : "<<wdl_amount<<endl;
cout<<"your current balance is: "<<cur_bal<<endl;
I have tried various things and your help would be appreciated.
thank you in advance.
>> I am having a hard time keeping the updated balances, can someone please help me?
Your math is wrong. The current balance (cur_bal) is what should be modified, not the other amounts.
Since the point of a class is to model the data of your program, why isn't the balance amount a data member of the Account class? It would be easy to maintain the changes to all of the balances, if the balance were contained in the class in the first place.
>> this is are my functions in a class called "functions"
This undermines the design of your account class.
thank you very much for your response.
the instructions of the assignment was to keep the information of the user in the header file within the Account class and all the deposit and withdrawal functions within the main in another class.
that is why I am having a bit of a hard time with this assignment.
This is all new stuff for me, so I am really racking my brain trying to learn.
any other tips or advice would be greatly appreciated.
whiteflags' response does not conflict with any of what you have been asked to do, and will in fact be precisely what is expected for your assignment.
Please look up what it means for something to be a member of a class.
You need to try to do as has been advised, and you may not get many further responses until you've shown your attempt at doing so, because that advice pretty much covers what you need to do.
So, to be perfectly clear, we are now waiting on you.