public class J6_7 {
final static int years = 30;
public static void main(String[] args) {
// TODO Auto-generated method stub
java.util.Scanner input = new java.util.Scanner(System.in);
System.out.print("The amount invested:");
double amountInvest =input.nextDouble();
System.out.print("Annual interest rate:");
double annualInterestRate = input.nextDouble();
double monthlyInterestRate = annualInterestRate /1200;
futureInvestmentValue(amountInvest,monthlyInterestRate,years);
}
public static double futureInvestmentValue(double investmentAmount,double monthlyInterestRate,int years) {
System.out.print("years \t Future Value\n");
double futureValue = 0;
for(int i=1;i<=years;i++) {
futureValue = investmentAmount * Math.pow(1+monthlyInterestRate, i*12);
System.out.println(i+"\t"+futureValue);
}
return 0;
}
}
java语言程序设计 第十版(基础篇)6.7
猜你喜欢
转载自blog.csdn.net/qq_41729287/article/details/83185343
今日推荐
周排行