Question: C++ Code: #include  #include  using namespace std; int main() SOLVED

Question: C++ Code: #include #include using namespace std; int main() SOLVED

C++ help with my Caculation

Code:

#include <iostream

#include <iomanip

using namespace std;

int main()

{

int number=1;

float save = 1;

int balance=1;

cout<< "What is your starting balance? ";

cin balance;

cout << balance << endl;

do

{

cout<< "How much money will you save/month? ";

cin save;

cout << save << endl;

}

while( save <= 0);

float interest = 1;

do

{

cout<< "What interest rate do you hope to earn? ";

cin interest;

cout << interest << endl;

}

while( (interest < 0) || (interest 100));

float months = 1;

do

{

cout<< "How many months do you want to save for ";

cin months;

cout << months << endl;

}

while(months <= 0);

float target = 1;

do

{

cout<< "What is your savings target? ";

cin target;

cout << target << endl;

}

while(target <= 0);


cout << setprecision(0) << fixed << "Balance: " << balance << " Save: " << save << " Int: " << balance * interest << "\nTotal: " << (balance * interest) + save + balance << endl;
/* I need this to loop based on the number of months*/

return 0;
}

Inputs:

1000
100
.10
3 - This is the number of months/loops that should be in the output
5000

Output:

Compiling...done.
Running...done.
What is your starting balance? 1000
How much money will you save/month? 100
What interest rate do you hope to earn? 0.1
How many months do you want to save for 3
What is your savings target? 5000
Balance: 1000 Save: 100 Int: 100
Total: 1200

***I need this to loop***

Expected Output:

Compiling...done.
Running...done.
What is your starting balance? 1000
How much money will you save/month? 100
What interest rate do you hope to earn? 0.1
How many months do you want to save for 3
What is your savings target? 5000
Balance: 1000 Save: 100 Int: 100
Total: 1200 /*Loop 1 0f 3*/

Balance: 1200 Save: 100 Int: 120
Total: 1420 /*Loop 2 0f 3*/

Balance: 1420 Save: 100 Int: 142
Total: 1662 /*Loop 3 0f 3*/
Powered by