Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help me write a nested for loop using the provided program I have been going at this for a week and it is logic
Please help me write a nested for loop using the provided program I have been going at this for a week and it is logic errors it is not producing the right answer so we have to debug the program above and get it to display the total earnings which is the current salary by percent increase by years until retirement or so i think.
Please help me understand this problem i have a brain injury (but still going to school) and cant grasp the concept it is due tonight at 11 59 est and the answers must be 77274 for 3% 78040 for 4% and 78813 for 5%
's In this lab, you will plan and create an algorithm for the problem specification shown in Figure 8-15. You begin by analyzing the problem, looking first for the output and then for the input. In this case, the program should display a person's total earnings before retirement at age 65, using annual raise rates of 3%, 4%, and 5%. To calculate the amounts, the program will need to know the person's age and current salary. Next, you plan the algorithm and then desk-check it. Figure 8-15 shows the completed IPO chart and desk-check table, which (for simplicity) uses an age of 62 and a salary of $25000. The algorithm contains two loops. The outer loop keeps track of the three annual raise rates (3%, 4%, and 5%). The nested loop keeps track of the number of years until retirement. Problem specification Create a program that allows the user to enter a person's age (in years) and current salary. Both input items should be entered as integers. The program should display a person's total earnings before retirement at age 65, using annual raise rates of 3%, 4%, and 5%. Display the total earning amounts as integers. Input Processing Output age (1-64 years) processing items: total earnings (at end of current salary raise rate (3%, 4%,5%) each of the years until years until retirement retirement) new salary year (counter) at this point, the current salary is year l's salary Algorithm: 1. enter the age 2. if (the age is less than 1 or greater than 64) display reenter message else enter current salary calculate years until retirement = 65-age repeat for each raise rate) assign current salary to new salary -assign current salary to total earnings repeat for (year 2 to years until retirement) new salary = new salary * (1 + raise rate) add new salary to total earnings end repeat display raise rate and total earnings end repeat end if current age 62 current salary 25000 raise rate years until retirement 3 .06 Figure 8-15 Problem specification, IPO chart, and desk-check table for the retirement algorithm (continues) year new salary 25000.0 25-50.0 26522.5 25000.0 total earnings 25000.. 50-50.0 3% rate total 4 25000.0 51000.0 0640.9 27049.0 4% rate total 26250.0 27562.5 51250.6 78812.5 5% rate total 4 Figure 8-15 Problem specification, IPO chart, and desk-check table for the retirement algorithm The fourth step in the problem-solving process is to code the algorithm into a program. Figure 8-16 shows the IPO chart information and corresponding C++ instructions. C++ instructions int age = 0; int current Salary = 0; IPO chart information Input age (1-64 years) current salary Processing raise rate (3%, 4%.5%) years until retirement new salary this variable is created and initialized in the for clause int years ToRetire = 0; double newSalary = 0.0; this variable is created and initialized in the for clause year (counter) Output double total = 0.0; total earnings (at end of each of the years until retirement) cout > age; if (age 64) 2. If the age is less than 1 or greater than 64) cout > currentSalary; calculate years until retirement = 65 - age yearsToRetire = 65 - age; repeat for (each raise rate) for (double rate = 0.03; rate onStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started