码迷,mamicode.com
首页 > 其他好文 > 详细

HW5.7

时间:2016-08-20 13:05:39      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

 

 1 import java.util.Scanner;
 2 
 3 public class Solution
 4 {
 5     public static void main(String[] args)
 6     {
 7         Scanner input = new Scanner(System.in);
 8 
 9         System.out.print("The amount invested: ");
10         double investAmount = input.nextDouble();
11         System.out.print("Annual interest rate: ");
12         double annualInterestRate = input.nextDouble();
13 
14         input.close();
15 
16         System.out.printf("%s\t%s\n", "Years", "Future Value");
17 
18         for(int i = 1; i <= 30; i++)
19             System.out.printf("%d\t%f\n", i, futureInvestmentValue(investAmount, annualInterestRate / 12, i));
20     }
21 
22     public static double futureInvestmentValue(double investmentAmount, double monthlyInterestRate, int years)
23     { return investmentAmount * Math.pow((1 + monthlyInterestRate), (years * 12)); }
24 }

 

HW5.7

标签:

原文地址:http://www.cnblogs.com/wood-python/p/5790060.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!