- package A01;
- import java.util.Scanner;
- public class A01 {
-
- public static void main(String[] args) {
- // TODO 自動產生的方法 Stub
- for(;;){
- try{
- Scanner s=new Scanner(System.in);
- int x,y;
- System.out.print("輸入分子: ");
- x=s.nextInt();
- System.out.print("輸入分母: ");
- y=s.nextInt();
- System.out.println(x+"/"+y+"="+(x/y));
- }
- catch(Exception e){
- System.out.println("程式發生錯誤");
- System.out.println("額外類別:"+e.toString());
- }
-
- }
- }
- }
複製代碼 |