Reference no: EM132644207
Question 1. RetirementSimulator should contain one main method that drives the entire simulation. There should he very little branching code in main . It should just call methods.
Question 2. A methodcalled userInputc This method should be responsible for gathering and verifying the user's inputs. If the user enters an invalid value, they should be prompted to re-enter the information until they enter a valid value. The user should be prompted for the following information:
• Initial Investment: The amount of money they currently have in their retirement account.
• Initial Salary: Their current salary.
• Salary Investment Range: The range (an upper and lower bound) of the percentage of salary they expect to save for retirement for any given year. The lower bound should not be below zero, and the upper bound should not be less than the lower bound.
• Investment Return Range:The range (an upper and lower bound), as a percentage, they expect as a return on their on investments. The lower bound can be negative as investments do lose money sometimes. Of course the upper bound should not be less than the lower bound.
• Yearly Raise Range: The range (an upper and lower bound) of percentage they expect their salary to increase in any given year. The lower bound can be negative but should not go below -100%, and the upper bound should not be less than the lower bound.
• Years to Retirement: The number of years until they plan to retire (this should be whole number -- no partial years.)
1. A runsimulation method. This method is responsible for creating a year-by-year simulation of the user's retirement account. For every year until the user can retire, runSimulation should randomly generate a number within the salary investment range. This number should be used to calculate the amount of money to be added to the investment account for that year. The simulation should then randomly generate a number within the investment return range. This number should be used to calculate how much the total investments earned (or lost) for that year. The investment total for that year should be adjusted to reflect the change in value. Finally, the method should randomly generate a number in the yearly raise range and adjust the salary accordingly. This new salary will be used to calculate the next year's retirement savings. Your simulation should contain a year 0 for the investment account that only includes the initial investment amount.
Question 2. A printResults method. It should display all the original values the user entered. It should then display the minimum, maximum, and average value the simulation generated for the yearly percentage of salary saved, the yearly rate of return, and the yearly salary increase, as well as the maximum salary the simulation used. Finally, it should display a histogram that represents the yearly changes in the user's investment account. In the histogram, the horizontal bars should be scaled such that the year in which the account had the most money has a bar 100 # characters long. Each bar should be followed by the total amount of money in the account that year (only 2 decimal points should be displayed).