- import java.util.Scanner;
- public class ch51
- {
- public static void main(String[] args)
- {
- Scanner s=new Scanner(System.in);
- int x, y;
- try
- {
- System.out.print("輸入分子: ");
- x=s.nextInt();
- System.out.print("輸入分母: ");
- y=s.nextInt();
- System.out.print(x+"/"+y+"="+(x/y));
- }
- catch(Exception e)
- {
- System.out.println("城市發生錯誤!");
- System.out.println("Error: "+e.toString());
- }
- }
- }
複製代碼 |