Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in Java Write a program that deals with inflation, which is essentially the rising cost of general goods over time. That is, the price of
in Java
Write a program that deals with inflation, which is essentially the rising cost of general goods over time. That is, the price of goods, such as a packet of peanuts, goes up as time goes by. So, you will write a program to gauge the expected cost of an item in a specified number of years. The program asks for the cost of the item, the number of years, and the rate of inflation. The output is the estimated cost of the item after that number of years, using the given inflation rate. The user enters the inflation rate as a percentage, for example 4.5. You will have to convert the percentage to a fraction (like o.o45), and then use a loop to estimate the item's price adjusted for inflation. Note that this is similar to computing compound interest on a credit values provided by the user to make sure that they are reasonable. Finally, you have to print out the price with exactly two places after the decimal (for the cents) after your calculations are done account or a mortgage. Also note that you must check each of the To adjust the price for inflation, you need to increase the price by the inflation rate each year. For example, if you have an item that is initially $10, with inflation rate of 10%, the adjusted prices will be After 1 year: $10.00 * (1+ 0.10) = $11.00 After 2 years: $11.0o (1 o.1o) $12.10 After 3 years: $12.10 (1 o.10)- $13.31 In other words, to calculate the price after another year, you have to use the value from the current year, NOT the original price. To do this, you must use a loop. An example of what your program should output: Enter the current price of the item: $10 Enter the number of years: 3 Enter the inflation rate as a percentage: 10 After 3 years, the price will be $13.31 You have been supplied JUnit tests for some simple valid examples, as well as negative price, negative year, and negative interest rateStep 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