返回列表 發帖
  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 x, y;
  8.                 try
  9.                 {
  10.                         System.out.print("輸入分子: ");
  11.                         x=s.nextInt();
  12.                         System.out.print("輸入分母: ");
  13.                         y=s.nextInt();
  14.                         System.out.print(x+"/"+y+"="+(x/y));
  15.                 }
  16.                 catch(Exception e)
  17.                 {
  18.                         System.out.println("城市發生錯誤!");
  19.                         System.out.println("Error: "+e.toString());
  20.                 }
  21.         }
  22. }
複製代碼

TOP

返回列表