Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Recommended Textbook for

Introductory Relational Database Design For Business With Microsoft Access

Authors: Jonathan Eckstein, Bonnie R. Schultz

1st Edition

1119329418, 978-1119329411

More Books

Students also viewed these Databases questions

Question

What is the money market?

Answered: 1 week ago

Question

1. Define and describe characteristics of intercultural conflict.

Answered: 1 week ago