package 本章總結; public class A02class { double Money = 0; public double showA(double money, int choice) { switch (choice) { case 1: Money = (money + money * 0.0603) / 36; break; case 2: Money = (money + money * 0.0612) / 60; break; case 3: Money = (money + money * 0.0639) / 240; break; default: A02 A = new A02(); A.main(null); break; } System.out.println("月供爲:"+Money); return Money; } } package 本章總結; import java.util.Scanner; public class A02 { public static void main(String[] args) { // TODO Auto-generated method stub A02class A02 = new A02class(); Scanner in = new Scanner (System.in); System.out.print("請輸入貸款金額:"); double Money=in.nextDouble(); System.out.print("請選擇貸款年限:1.3年(36個月) 2.5年(60個月) 3.20年(240個月):"); int choice =in.nextInt(); A02.showA(Money, choice); } }