Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone write a program for me in Java that takes user input about an item a

ID: 3630684 • Letter: C

Question

Can someone write a program for me in Java that takes user input about an item and then outputs the price of the item based on the number of years in the future, and the inflation rate?

the output should look like this (please note that a // means it is my comments, and should not be a part of the output).

Enter item description: //display
Television //user input
Enter the cost of the item, with no dollars signs //display
1000 //user input
Enter the number of years from now when you will be purchasing the item: //display
5 //user output
Enter the rate of inflation as a decimal number. For example enter 5.6% as 5.6 //display
3.5 //user input
in 5 years from now your item that costs 1000.00 now will cost 1187.69 //display
//end

for this, please don't use anything more advanced than for or while loops, and if, else functions. please also include one other method other than the main method.

Thanks for much guys! i appreciate all your hard work and assistance.

Explanation / Answer

please rate - thanks

I debugged the previous answer

import java.util.*;
/*import Scanner class*/

/*Note: this class does not verify the validity of the user input*/
public class Inflation{

public static void main(String[] args){

Scanner scan = new Scanner(System.in);
String description;
double cost, inflation, futureCost;
int years;

/*Input description*/
System.out.println("Enter item description: ");
description = scan.nextLine();

/*Input item cost*/
System.out.println("Enter the cost of the item, with no dollars signs: ");
cost = scan.nextDouble();

/*Input number of years*/
System.out.println("Enter the number of years from now when you will be purchasing the item: ");
years = scan.nextInt();

/*Input rate of inflation*/
System.out.println("Enter the rate of inflation as a decimal number. For example enter 5.6% as 5.6: ") ;
inflation = scan.nextDouble();

/*Method for calculation of future cost after inflation */
futureCost = calculate(cost, years, inflation);

System.out.printf("In %d years from now your %s that costs %.2f now will cost %.2f ",years,description,cost,futureCost);
}

public static double calculate(double cost, int years, double inflation){
/*Temporary variable for years and cost */
int tempYear = years;
double tempCost = cost;
while(tempYear > 0){

/*For every year, take the cost and and the percentage of the cost as inflation */
tempCost = tempCost + (tempCost * (inflation/100.));

tempYear--; /*decrement number of years by one each time in the loop */
}
return tempCost;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote