- import java.util.Scanner;
- public class Hello {
- public static void main(String[] args) {
- // TODO 自動產生的方法 Stub
- Scanner s=new Scanner(System.in);
- try
- {
- int x ,y;
- System.out.print("請輸入分子:");
- x=s.nextInt();
- System.out.print("請輸入分母:");
- y=s.nextInt();
- System.out.println("x/y="+(x/y));
- }catch(Exception tim)
- {
- System.out.println("出錯了");
- System.out.println("在"+tim.toString()+" 錯了");
- }finally
- {
- System.out.println("?!?!");
- }
- }
- }
複製代碼 |