Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ ... the code below works fine... but I want it to work for as many years as I can... right now I am writing

C++ ... the code below works fine... but I want it to work for as many years as I can... right now I am writing out the code one year at a time, so i need a loop (later i will change it so that the user can choose as many years as they want to print out: cin). The loop needs to print out years - but the code works the math into months because it is compound interest... There is extra commented out stuff that I used to help make to program. I hope it helps instead of confuses you. The image at the bottom is what the program is suppose to look like according to the assignment. Thanks!

#include

#include

#include

#include

using namespace std;

int main()

{

double startInvest;

double mDeposit;

double newTotal;

double aInterest; //%

double convertInterest;

double newInterest;

double bigInterest;

double endClosing;

startInvest = 1.00;

mDeposit = 50.00;

aInterest = 5;

convertInterest = (aInterest / 100);

newInterest = (convertInterest / 12);

endClosing = (startInvest + bigInterest);

string headOne;

// string headTwo;

// string headThree;

// string headFour;

string headFive;

string headSix;

headOne = "Year |"; // 1-60 //1

//headTwo = "OpenAmount"; //startInvest //2

//headThree = "DepositAmount"; // mDeposit //3

//headFour = " NewTotal"; // startInvest + mDeposit //4

headFive = "Year End Interest |"; // bigInterest //5

headSix = "Year End Balance |"; // NewTotal + AddInterest //6

cout

//cout

//cout

//cout

cout

cout

for (int month = 0; month

newTotal = startInvest + mDeposit;

endClosing = newInterest + newTotal;

std::cout

if (month == 11){

cout

cout

newInterest; //--- need this after 12 months to print

cout

endClosing

}

if (month == 23){

cout

cout

newInterest; //--- need this after 12 months to print

cout

endClosing

}

if (month == 35){

cout

cout

newInterest; //--- need this after 12 months to print

cout

endClosing

}

if (month == 47){

cout

cout

newInterest; //--- need this after 12 months to print

cout

endClosing

if (month == 59){

cout

cout

newInterest; //--- need this after 12 months to print

cout

endClosing

}

newInterest = ((newTotal*convertInterest) / 12);

endClosing = (newTotal + newInterest);

startInvest = endClosing;

}

return 0; }

image text in transcribed

Balance and Interest with Additional Monthly Deposits Year Year End Balance Year End Earned Interest 1 $617.55 $16.55 2 $1265.65 $48.10 3 $1946.90 $81.25 4 $2663.01 $116.11 5 $3415.76 $152.75

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Are robots going to displace all workers? Explain your answer.

Answered: 1 week ago