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;
}

>>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;

This article has been dead for over six months. Start a new discussion instead.