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

TOP

返回列表