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

HW4.31

时间:2016-08-19 00:54:49      阅读:127      评论: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("Enter the balance: ");
10         double balance = input.nextDouble();
11         System.out.print("Enter the annual interest rate: ");
12         double rate = input.nextDouble();
13         System.out.print("Enter the number of month: ");
14         int numberOfMonths = input.nextInt();
15 
16         input.close();
17 
18         System.out.printf("%10s\t%10s\n", "Month", "CD Value");
19 
20         for(int i = 0; i < numberOfMonths; i++)
21         {
22             balance = balance * (1 + rate / 12);
23             System.out.printf("%10d\t%10f\n", i + 1, balance);
24         }
25     }
26 }

 

HW4.31

标签:

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

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