Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

USING C++ For the following problem: a. write a hierarchy chart b. write code fo

ID: 3692490 • Letter: U

Question

USING C++

For the following problem:

a. write a hierarchy chart

b. write code for main and all other modules

c. trace

1. Design an algorithm that will prompt for and receive your current check book balance, followed by a number of financial transactions. Each transaction consists of a transaction code and a transaction amount. The code can be a 'D' for deposit or 'C' for check. Your program is to add each deposit amount to the balance and subtract each check amount. After each transaction is processed, a new running balance is displayed, with a warning message if the balance becomes negative. When there are no more transactions a 'Q' is entered as the transaction code. Your algorithm is to then display the initial and final balance along with the number of checks and deposits that were made.

Explanation / Answer

#include <iostream>
#include <iomanip>
#include <math.h>

using namespace std;

void MoneyFunct(float &CashLeft, float StartBal, char TransacType,
float Transac, int Q, float TotalServiceCharge);

int main() {
char TransacType;
float StartBal;
float Transac;
float CashLeft;
float TotalServiceCharge;
cout << "Enter your starting balance: ";
if (cin >> StartBal)
CashLeft = StartBal;
else
{
std::cerr << "unable to read StartBal from cin ";
exit(EXIT_FAILURE);
}
do {
cout << "Now enter your transaction."
<< "Enter Q there are no more transactions" << endl;
cout << "Enter transaction type: ";
cin >> TransacType;
cout << endl;
cout << "Enter the amount for your transaction: ";
cin >> Transac;
cout << endl;
MoneyFunct;
cout << "You have $" << CashLeft
<< " remaining in your account" << endl
<< "Your total service charges are "
<< TotalServiceCharge << endl;
} while (TransacType != 'Q');

CashLeft = CashLeft + TotalServiceCharge;
cout << endl << "Your final balance is "
<< CashLeft << "." << endl
<< "Your total service charges are "
<< TotalServiceCharge << "." << endl
<< "Thanks for using the checkbook balancer!" << endl;
return 0;
}

void MoneyFunct(float &CashLeft, float StartBal, char TransacType,
float Transac, int Q, float TotalServiceCharge)
{
Q == 4;
TotalServiceCharge = 0;
if (TransacType == 'C') {
CashLeft = CashLeft - Transac;
TotalServiceCharge = TotalServiceCharge + 0.15;
} else if (TransacType == 'D') {
CashLeft = CashLeft + Transac;
TotalServiceCharge=TotalServiceCharge+0.10;
}

if (CashLeft <= 50 && CashLeft >= 0) {
cout << "Your balance is lower than $50." <<
<< "If your balance becomes negative "
<< "you will be charged $10" << endl;
}

if (CashLeft < 0) {
cout << "Your balance has become negative." <<
<< "A $10 charge will be subtracted "
<< "from your balance." << endl;
TotalServiceCharge = TotalServiceCharge+10;
}
}