Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a. Test the program using 62 as the age and 25000 as the current salary. The total earning amounts should be $77273, $78040, and $78813.

a. Test the program using 62 as the age and 25000 as the current salary. The total earning amounts should be $77273, $78040, and $78813. If necessary correct any bugs (errors) in the program.

b. Change the outer for loop to a posttest loop.

#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

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions

Question

Define capitation and how capitation is calculated for prepayment

Answered: 1 week ago