- import java.util.Scanner;
- public class Ch22 {
- public static void main(String[] args) {
- {
- for(;;)
- {
- try
- {
- Scanner s=new Scanner(System.in);
- ;
- int x,y;
- System.out.print("輸入分子");
- x=s.nextInt();
- System.out.print("輸入分母");
- y=s.nextInt();
- }catch(Exception e)
- {
- System.out.println("程式錯誤");
- System.out.println("例外類別");
- }
- System.out.println();
- }
- }
- }
- }
複製代碼 |