Question: 1. Change the outer for loop to a posttest loop. Test the program. #include #include using namespace std; int main ( ) { int age

1. Change the outer for loop to a posttest loop. Test the program.

#include

#include

using namespace std;

int main ( )

{

int age = 0;

int currentSalary = 0;

int yearsToRetire = 0;

double newSalary = 0.0;

double total = 0.0;

cout << fixed << setprecision(0);

cout << "Current age in years (1 to 64): ";

cin >> age;

if (age < 1 || age > 64)

cout << "Please enter an age from 1 to 64." << end1;

else

{

cout << "Current salary as a whole number: ";

cin >> currentSalary;

cout << end1;

yearsToRetire = 65 - age;

for (double rate = 0.03; rate < 0.06; rate += 0.01)

{

newSalary = currentSalary; //year 1 salary

total = currentSalary; //year 1 salary

for (int year = 2; year <= yearsToRetire; year += 1)

{

newSalary *= (1 + rate);

total += newSalary;

} // end for

cout << "Total with a" << rate * 100

<< "% annual raise: $" << total << end1;

} // end for

} // end if

return 0;

} // end of main function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!