Create a program that displays the ending balance in a savings account, given th
ID: 1153833 • Letter: C
Question
Create a program that displays the ending balance in a savings account, given the beginning balance, the deposit amounts, and the withdrawal amounts. Use two loops in the program: one to get the deposit amounts, and the other to get the withdrawal amounts.
a. Create an IPO chart for the problem, and then desk-check the algorithm two times, using the data shown in Figure 7-52.
b. List the input, processing, and output items, as well as the algorithm, in a chart similar to the one shown earlier in Figure 7-42. Then code the algorithm into a program.
c. Desk-check the program using the same data used to desk-check the algorithm.
d. Create a program that display the ending balance with two decimal places. e. Test the program using the same data used to desk-check program.
Explanation / Answer
Answer:
Figures are not shared in the question and I am answering your first question.
Create a program that displays the ending balance in a savings account, given the beginning balance, the deposit amounts, and the withdrawal amounts. Use two loops in the program: one to get the deposit amounts, and the other to get the withdrawal amounts.
code:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double startBalance;
cout<<"Enter the starting balance: ";
cin>>startBalance;
cout<<"Enter the amounts deposited(Enter -1 to quit): ";
double deposit = 0.0;
double endBalance= startBalance;
while(deposit != -1)
{
cin>>deposit;
if(deposit == -1)
break;
endBalance+= deposit;
}
cout<<"Enter the withdrawal amounts (Enter -1 to quit): ";
double encashed = 0.0;
while(encashed != -1)
{
cin>>encashed;
if(encashed== -1)
break;
endBalance -= encashed;
}
cout<<"Ending balance in the account after given transactions is: "<<fixed<<setprecision(2)<<endBalance<<endl;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.