examp3_4.java

来自「Java与面向对象程序设计实验教学讲义.复数类的实现,复数类的复杂运算,身份证号」· Java 代码 · 共 20 行

JAVA
20
字号
import java.text.*;
public class Examp3_4 {
        public static void main(String[] args){
        double original,money,interest;
        int years = 0;
        original = money= 10000;
        interest = 11.25 / 100;
        System.out.println("year  money");
        while (money < 2 * original) {
            years = years + 1;
            money = money + (interest * money);
            System.out.println(" " + years + "    " +
                                new DecimalFormat("0.00").format(money));
      }
      System.out.println();
      System.out.println(" 第 " + years + " 年存款额达到 " +
                       new DecimalFormat("0.00").format(money) + "元。");
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?