First off thanks to anyone willing to give their time to help a newbie.
So im very new to java/programming and im having trouble with a program. I believe the while loop is messed up as im new to using them. The program is used to calculate inflation in price of an object. The user enters the price, amount of years, and percent inflation. When i try to run this, it cannot print my "finalamount" variable, and i cant figure out what i messed up. Any help/suggestions would be great.
import java.util.Scanner; public class inflationcalculator { public static void main(String[] args) { /*Gather user input*/ System.out.print("Input the current cost of the item, just the number:"); Scanner scan = new Scanner(System.in); int amount = scan.nextInt(); System.out.print("Input the rate of inflation, as a percentage without the percent sign:"); int inflat = scan.nextInt(); System.out.print("Input the number of years, must be a whole number:"); int numyear = scan.nextInt(); /*Calculate the inflation according to the users input*/ int counter = 0; double percent = (inflat/100); double amountedit = amount; while(counter < numyear){ double finalamount = (amountedit + (amountedit*percent)); counter++; } /*Print/results screen*/ System.out.print("At "); System.out.print(inflat); System.out.print(" percent inflation per year, the cost in "); System.out.print(numyear); System.out.print(" year(s) will be $"); System.out.print(finalamount); System.out.print("."); } }