- public class interest
- {
- public static void main(String args[])
- {
- double r=0.05;
- int p = 1000;
- int n = 10;
- int m1,m2;
- System.out.println("年 A銀行(複利) B銀行(單利)");
- System.out.println("----------------------------------------");
- for(int i = 1; i <= n ; i++)
- {
- m1 = (int)(p * Math.pow( (1+r) , i ));
- m2 = (int)(p * ( 1 + r*i ));
- System.out.printf("%d\t%d\t\t%d\n",i,m1,m2);
- }
- System.out.println("----------------------------------------");
- }
- }
複製代碼 |