返回列表 發帖
  1. import java.util.Scanner;
  2. public class Ch51{
  3.        public static void main(String args[]){
  4.               while(true){
  5.                   try{
  6.                   int x,y;
  7.                         Scanner s=new Scanner(System.in);
  8.                         System.out.print("請輸入分子");
  9.                         x=s.nextInt();
  10.                         System.out.print("請輸入分母");
  11.                         y=s.nextInt();
  12.                         System.out.println("答案為: "+(x/y));
  13.                   }
  14.                   catch(Exception e){
  15.                                   System.out.println("程式發生錯誤");
  16.                                   System.out.println("例外: "+ e.toString());
  17.                   }
  18.               }
  19.        }
  20. }
複製代碼
ABCDEFGHIJKLMNOPQRSTUVWXYZ

TOP

返回列表