计算如果每年按7.5%的年利率复合计算,2500美元的投资至少价值5000美元所需的年数
/** 来自 n o w j a v a . c o m**/ 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; /** 来 自 nowjava.com - 时代Java **/ while (currentInvest <= finalInvest) { years = years + 1; currentInvest = currentInvest * 1.075; }