返回列表 發帖
本帖最後由 曾挺桂 於 2016-6-17 20:59 編輯

import java.util.Scanner;
public class Ch52
{
    static Scanner s=new Scanner(System.in);
    public static void main(String[] args)throws MyException
    {
        Float x,y;
        System.out.print("輸入分子: ");
        x=s.nextFloat();
        System.out.print("輸入分母: ");
        y=s.nextFloat();
        if(y==0)
            throw new MyException("0!!!!!!!!!!!!");
        System.out.println(x+"/"+y+"="+(x/y));
    }
}
class MyException extends Exception
{
      MyException(String str)
      {
          super(str);
      }
}
class MyException extends Exception
{
      MyException(String str)
      {
          supert(str)
      }
}[/code]

TOP

返回列表