954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Updating Balance

I am creating a check register for class. We are working on functions - pass by value and pass by reference. I have created all my functions and they seem to be working. However; there is a problem with my currentBal calcuation. When you have an inital transaction the transAmt gets deducted from begBal which will give you a current balance. My problem is when the 2nd function is called and I need to take the current balance and add $$$ for a deposit. When the money is added it gets added to the begBal not the current balance. I have commented some lines of code out when errors have beenr received.

My functions are pasted below. Can someone take a look and let me know where I am going wrong?

Thanks!

double ProcessCheck(double begBal, double& transAmt){
		double currentBal;
		currentBal = begBal - transAmt;
		//GetBegBal();
		cout <<endl <<"Check =" << setw(16) << transAmt << setw(36) << "Balance = $  " << currentBal << endl;
		begBal = currentBal;
		return begBal;
}


double ProcessDeposit(double& currentBal, double& transAmt){
	//double begBal;
	//currentBal = begBal + transAmt;
	cout <<endl <<"Deposit =" << setw(16) << transAmt << setw(36) << "Balance = $  " << currentBal << endl;
	return currentBal;
}

double ProcessATM(double& currentBal, double& transAmt){
	cout <<endl <<"ATM =" <<setw(16) << transAmt << endl << "ATM Fee $ 2.00" << setw(36) << "Balance= $ "
		<< currentBal;
	return currentBal;
}
indygirl
Newbie Poster
1 post since Oct 2007
Reputation Points: 10
Solved Threads: 0
 

>>When the money is added it gets added to the begBal not the current balance

In ProcessDeposit() why not simply add the transaction amount to the current balance?
Change line 15 to this: currentBal += transAmt;

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You