So I have a homework to do where I have to make a loop. The goal is to make the computer calculate how many years it will take me to reach my goal if I put lets say 300 dollars every year and how much I will have after having interest calculated. This code I have below is not really complete, just an exemple.
Help would be appreciated.
#include <iostream>
using namespace std;
int; float main()
{
int nr1;
int nr2;
float nr3;
int nr4;
float nr5;
cout << "How much you want to save every year: \n";
cin >> nr1;
cout << "What is your goal: \n";
cin >> nr2;
cout << "How much interest in percent: \n";
cin >> nr3;
while (true)
{
cout << "Your goal will be reached after: " << nr4 << endl;
cout << "Your salery will then be: " << nr5 << endl;
break;
}
cout << "How much you want to save every year: \n";
cin >> nr1;
cout << "What is your goal: \n";
cin >> nr2;
cout << "How much interest in percent: \n";
cin >> nr3;
Perhaps instead, something far more readable
1 2 3 4 5 6 7 8
cout << "How much you want to save every year: \n";
cin >> annualSavings;
cout << "What is your goal: \n";
cin >> desiredTarget;
cout << "How much interest in percent: \n";
cin >> interestRate;
At least then, you might be able to construct a readable loop, like