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

HW4.7

时间:2016-08-14 13:01:03      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

 

 1 public class Solution
 2 {
 3     public static void main(String[] args)
 4     {
 5         double rate = 0.05;
 6         double balance = 10000;
 7         double sum = 0;
 8 
 9         for(int i = 0; i < 10; i++)
10             balance = balance * (1 + rate);
11 
12         System.out.println("The cost after 10 years is " + balance);
13 
14         for(int i = 0; i < 4; i++)
15         {
16             balance = balance * (1 + rate);
17             sum += balance;
18         }
19 
20         System.out.println("The total cost of 4 years: " + sum);
21     }
22 }

 

HW4.7

标签:

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

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