You are required to write a C++ program to read in one customer’s account balance at the beginning of the month, a total of all withdrawals for the month, and a total of all deposits made during the month. A federal tax charge of 1% is applied to all transactions made during the month. The program is to calculate the account balance at the end of the month by
(1) subtracting the total withdrawals from the account balance at the beginning of the month, (2) adding the total deposits to this new balance,
(3) calculating the federal tax (1% of total transactions, i.e.total withdrawals + total deposits),
(4) subtracting this federal tax from the new balance.
After these calculations, print the final end-of-month balance.
This will be a straightforward translation into pseudocode. As this is a homework assignment¸ you'll have to do the legwork yourself. Just evaluate each step in turn:
input: accountBalanceStart, totalDeposits, totalWithdrawals
output: accountBalanceEnd
Let's take the first step:
accountBalanceEnd <-- accountBalanceStart - totalWithdrawals
Now the second:
accountBalanceEnd <-- accountBalanceEnd + totalDeposits
Next, compute the tax and subtract it:
accountBalanceEnd <-- accountBalanceEnd - (totalWithdrawals + totalDeposits) * 0.01
Finally, show the result:
print accountBalanceEnd
Comments
Leave a comment