Java examples for File Path IO:Scanner
calculates the amount of years that it will take for a $2500 investment to be worth at least $5000 if compounded annually at 7.5%
import java.util.Scanner; public class Investment { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int Invest = 2500; int finalInvest = 5000; double currentInvest = Invest; double years = 1; while (currentInvest <= finalInvest) { years = years + 1;/*from w w w . j a v a 2 s. c o m*/ currentInvest = currentInvest * 1.075; } System.out.println("It'll take you " + (int) years + " years"); } }