返回列表 發帖

[作業] if...else if...else 判斷式

本帖最後由 tonyh 於 2014-5-17 14:33 編輯

  1. import java.io.Console;
  2. public class ch11
  3. {
  4.     public static void main(String args[])
  5.     {
  6.         Console c=System.console();
  7.         int x,y;
  8.         System.out.print("請輸入x: ");
  9.         x=Integer.parseInt(c.readLine());
  10.         System.out.print("請輸入y: ");
  11.         y=Integer.parseInt(c.readLine());
  12.         System.out.println("您剛輸入的x為"+x+",y為"+y);
  13.         if(x>y)
  14.             System.out.println("x>y");
  15.         else if(y>x)
  16.             System.out.println("y>x");
  17.         else
  18.             System.out.println("x=y");
  19.     }
  20. }
複製代碼
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

返回列表