标签:
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 }
标签:
原文地址:http://www.cnblogs.com/wood-python/p/5769938.html