返回列表 發帖
  1. import java.util.Scanner;
  2. public class ch51
  3. {
  4.     public static void main(String args[])
  5.     {
  6.         Scanner s=new Scanner(System.in);
  7.         int a,b;
  8.         try
  9.         {
  10.         System.out.print("請輸入分子: ");
  11.         a=s.nextInt();
  12.         System.out.print("請輸入分母: ");
  13.         b=s.nextInt();
  14.         System.out.println(a+"/"+b+"="+(a/b));
  15.         }
  16.         catch(Exception e)
  17.         {
  18.            System.out.println("程式出現錯誤");
  19.            System.out.println("錯誤類別: "+e.toString());
  20.         }
  21.     }
  22. }
複製代碼

TOP

返回列表