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

  2. public class java01 {

  3.         public static void main(String[] args) {
  4.                 for (;;)

  5.                 {

  6.                         try

  7.                         {
  8.                                 Scanner s = new Scanner(System.in);

  9.                                 int x, y;
  10.                                 System.out.print("輸入分子");
  11.                                 x = s.nextInt();
  12.                                 System.out.print("輸入分母");
  13.                                 y = s.nextInt();
  14.                                 System.out.println(x + "/" + y + "=" + (x / y));
  15.                         } catch (Exception e) {
  16.                                 System.out.println("程式發生錯誤");
  17.                                 System.out.println("例外類別"+e.toString());
  18.                         }
  19.                         System.out.println();
  20.                 }

  21.         }
  22. }
複製代碼

TOP

返回列表