I am trying to make a program that calculates a bonus/raise every year with 3 different interest rates, and the loop should end when the user inputs 0 with a good bye.
I have resulted in using a while {if{for{for}}} else nested loop, but how can I remove the if else statement and use only do while nested loops?
This is what I have so far as my program:
int main()
{
double salary;
double raise;
while (1)
{
cout << "Enter a salary: ";
cin >> salary;
if (salary != 0)
{
for(int rate = 3; rate <= 5; rate++)
{
cout << "Raite rate: " << rate << "%" << endl;
double temp = salary;
for(int year = 1; year <= 4; year++)
{
raise = (temp * rate) / 100;
temp += raise;
cout << setw(14) << "Year: " << year << ", " << fixed << setprecision(2);
cout << "Raise: $" << raise << ", " << "Salary: " << temp << endl;
}
}
}
else {
break;
}
}
cout << "Good bye!";
return 0;
}
I want to remove the if else statements and make it run the same.