Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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 writea program to gauge the expected cost of an item in a specified number of years. The program asks for the cost of t 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.045), 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 card account or a mortgage. Also note that you must check each of the 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 he item, the number of years, and the rate of inflation. The output is the estimated cost of the item 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.oo(o.10) $11.00 After 2 years: $11.0o(10.10) $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: $1e 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 rate

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

Successful Keyword Searching Initiating Research On Popular Topics Using Electronic Databases

Authors: Randall MacDonald, Susan MacDonald

1st Edition

0313306761, 978-0313306761

More Books

Students also viewed these Databases questions