/** from 时代Java公众号**/
public class Main
{
public static void main(String args[])
{
double amount; // amount on deposit at end of each year
double principal = 1000.0; // initial amount before interest
double rate = 0.05; // interest rate
// display headers
System.out.printf("%s%20s%n", "Year", "Amount on deposit");
// calculate amount on deposit for each of ten years
for (int year = 1; year <= 10; year++)
{
// calculate new amount for specified year
amount = principal * Math.pow(1.0 + rate, year);
// display the year and the amount
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。