Write a program that calculates the closing balance for an indeterminate number of checkbooks. The program must logically flow as follows:
Firstly) You must Ask for data for the first checkbook- opening balance, withdrawals and deposits
Secondly) Display the opening balance, the number of withdrawals, the number of deposits and the closing balance
lastly) Ask the user if he wishes to calculate the balance on another checkbook:
If the input says yes, go back to Step 1 and perform the rest of the steps.
If not end the program
All data must be standard input. The format is a series of numbers, the first of which is the opening balance. Thereafter, the user will enter withdrawals as negative numbers and deposits as positive numbers. Input will indicate the finish of the monetary data by inputting zero. The user will enter a lower case 'y' to select the option of balancing another checkbook; otherwise, the user will enter a lower case 'n'.
#include <iostream>
#define CONT true // preprocessor macro.
usingnamespace std;
int main(){
double balance,input,totalWithdrawals,totalDeposits;
// I'm assuming totalWithdrawals and totalDeposits are not functions, but values.
do {
cout << "\nEnter the current balance on the account: ";
cin >> balance;
cout << "\nEnter withdrawal or deposit amount: ";
cout << "\nEnter 0 to end program"
cin >> input;
switch(input)
case (input < 0):
totalWithdrawals++;
break;
case (input > 0)
totalDeposits++;
break;
default:
return 0;
break;
}
balance += input;
cout << "Balance = "<< balance << endl;
cout << "Deposit count = " << totalDeposits << endl;
cout << "Withdrawal count = " << totalWithdrawals << endl;
} while (CONT == true);
}
EDIT: forgot the code blocks. This may or may not be within the constraints, then again, I don't really care. If it isn't, it's up to you to make it fit said constraints.