返回列表 發帖
  1. package A01;
  2. import java.util.Scanner;

  3. public class A01 {
  4.        

  5.         public static void main(String[] args) {
  6.                 // TODO 自動產生的方法 Stub
  7.                 for(;;){
  8.                         try{
  9.                 Scanner s=new Scanner(System.in);
  10.                 int x,y;
  11.         System.out.print("輸入分子: ");
  12.         x=s.nextInt();
  13.         System.out.print("輸入分母: ");
  14.         y=s.nextInt();
  15.         System.out.println(x+"/"+y+"="+(x/y));
  16.                 }
  17.                 catch(Exception e){
  18.                         System.out.println("程式發生錯誤");
  19.                         System.out.println("額外類別:"+e.toString());
  20.                 }
  21.                

  22.         }

  23. }
  24. }
複製代碼

TOP

返回列表