Problem 2. (expectedcost) it is difficult to make a budget that spans several years, because prices are not stable. if your company needs 200 pencils per year, you cannot simply use this year’s price as the cost of pencils two years from now. because of inflation the cost is likely to be higher than it is today. 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 from now that the item will be purchased, and the rate of inflation. the program then outputs the estimated cost of the item after the specified period. have the user enter the inflation rate as a percentage, such as 5.6 (percent). your program should then convert the percentage to a fraction,

Respuesta :

The program that outputs the estimated cost of the item after the specified period with inflation rate as a percentage and convert the percentage to a fraction is; As written below

How to write a program in Java?

The input for this program is;

import java.util.Scanner;

public class TestDemo {

public static void main(String[] args) {

 double cost, inflation;

 int years;

 Scanner input = new Scanner(System.in);

 System.out.print("Enter the cost :");

 cost = input.nextDouble();

 System.out.print("Enter the number of years:");

 years = input.nextInt();

 System.out.print("Enter the inflation rate:");

inflation = input.nextDouble() * .01;

 for (int i = 0; i < years; i++)

  cost += cost * inflation;

 cost = (int) (cost * 100) / 100.0;

 System.out.println("Item will cost about $ " + cost + " in " + years + " years. " );

}

}

The output is;

Enter the cost :2000

Enter the number of years:12

Enter the inflation rate:0.056

Item will cost about $ 2013.48 in 12 years.

Read more about Java Programming at; https://brainly.com/question/18554491