It pretty much works fine...except for the fact that it wont output the total amount of withdrawals and deposits. I have no idea how to make it do that. Can anyone help?
#include <iostream>
using namespace std;
float userInput()
{
float balance;
cout << "Please enter your current checkbook balance..." << endl;
cin >> balance;
return balance;
}
float useMoney(float deposit, float withdrawal)
{
float total = 0;
float cash;
cout << "If you would like to make a withdrawal, please enter a negative number." << endl;
do
{
cout << "You may now either make a withdrawal or a deposit." << endl;
cout << "Typing a zero (0) will terminate your transaction." << endl;
cin >> cash;
total += cash;
if(cash > 0)
deposit++;
else if(cash < 0)
withdrawal++;
}
while(cash != 0);
return total;
}
char endingData(float balance, float withdrawal, float deposit, float total)
{
char choice;
cout << "Opening balance: " << balance << endl;
cout << "Number of Withdrawals: " << withdrawal << endl;
cout << "Number of Deposits: " << deposit << endl;
balance += total;
cout << "Closing balance: " << balance << endl;
cout << "Would you like to balance another checkbook?" << endl;
cout << "Type 'y' for yes or type 'n' for no and to quit the program." << endl;
cin >> choice;
return choice;
}
int main()
{
char choice;
float balance, withdrawal, deposit, cash, total;
balance = 0;
cash = 0;
withdrawal = 0;
deposit = 0;
total = 0;
do
{
balance = userInput();
total = useMoney(deposit, withdrawal);
choice = endingData(balance, deposit, withdrawal, total);
}
while(choice == 'y');
}
It pretty much works fine...except for the fact that it wont output the total amount of withdrawals and deposits. I have no idea how to make it do that. Can anyone help?