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

C++ Using a loop, accept a starting balance as input from users for an investmen

ID: 3850812 • Letter: C

Question

C++

Using a loop, accept a starting balance as input from users for an investment, continuously prompting users for the investment until they enter a value greater than zero.

Using a separate loop, produce a table of values showing the year, interest gained that year, and the closing balance for that year. Assume a 5% annual interest rate and an investment period of 10 years.

Be sure to name all variables and constants properly as per the style guide

You must include complete program documentation:

Block comment at the top of your code with Application Author, Application Name, Date of Creation, and a detailed Description

Single line comments describing each variable/constant

Block comments calling attention to your input/processing/output sections

Other single line comments as necessary

CAUsersAUMDesktopMPROG1710MWeekFivelBarlowlceFive.exe Please enter the starting balance of your investment: $1000.00 Balance Year Interest $50.00 $1050.00 $52.50 $1102.50 $55.12 $1157.62 $57.88 $1215.51 $1276.28 $60.78 $63.81 $1340.10 $67.00 $1407.10 $70.36 $1477.46 $1551.33 $73.87 $1628.89 $77.57 10 Press any key to continue

Explanation / Answer

#include <iostream>
using namespace std;

int main()
{
    float start_balance,new_total=0;     //defining variables(start_balance is the starting balance)
    int i;
    cout << "Enter starting balance of your investment ";   //asking user for initial input
    cin >> start_balance;
  
    while ( start_balance > 0) {                              //loop will continue till balance entered by user is greater than zero
   cout<<"year"<<"     "<<"interest"<<"      "<<"balance"<<endl;    //printing table header
        new_total=new_total+start_balance;      //calculating new balance

        for (i=1;i<=10;i++){                       //looping 10 times for 10 years
       interest=new_total*1*5/100;    //calculating interest
       new_total=new_total+interest;      //claculating new principle amount or balance for next year
       cout<<i<<"    "<<interest<<"     "<<new_total<<endl;
   }

   cout << "Enter starting balance of your investment(more than zero to continue) ";
   cin >> start_balance;


   }

  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote