返回列表 發帖
  1. package main;

  2. import java.util.Scanner;

  3. public class Main {

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

  22. }
複製代碼

TOP

返回列表