返回列表 發帖
  1. package mhjh.mtc;

  2. import java.util.Scanner;

  3. public class WWW {

  4.         public static void main(String[] args) {
  5.                 // TODO 自動產生的方法 Stub
  6.         Scanner scanner= new Scanner(System.in);
  7.         System.out.println("請輸入分子");
  8.         int num1=scanner.nextInt();
  9.         System.out.println("請輸入分母");
  10.         int num2=scanner.nextInt();
  11.         int result=0;
  12.         try{
  13.                 result=num1/num2;
  14.         }
  15.         catch(Exception ex)
  16.         {
  17.           System.out.println(ex.toString());
  18.         }
  19.         System.out.println(result);
  20.         
  21.         }

  22. }
複製代碼

TOP

返回列表