返回列表 發帖

if... else 判斷式

  1. import java.lang.*;
  2. import java.io.Console;
  3. public class ch07
  4. {
  5.    public static void main(String args[])
  6.    {
  7.         Console console=System.console();
  8.         int score;
  9.         System.out.print("請輸入你的成績: ");
  10.         score=Integer.parseInt(console.readLine());
  11.         if(score>=60)
  12.         {
  13.             System.out.println("恭喜你及格了!");
  14.         }else
  15.         {
  16.             System.out.println("不及格!下次再努力!");
  17.         }
  18.    }
  19. }
複製代碼

  1. import java.lang.*;
  2. import java.io.Console;

  3. public class ch07
  4. {
  5.        public static void main (String args[])
  6.        {
  7.               Console console=System.console();
  8.               int score;
  9.               System.out.print("請輸入分數:");
  10.               score=Integer.parseInt(console.readLine());
  11.               if(score>=60)
  12.               {
  13.                  System.out.print("恭喜你及格了!!");
  14.               }
  15.               else
  16.               {
  17.                  System.out.print("下次再努力!!");
  18.               }
  19.        }
  20. }
複製代碼

TOP

  1. import java.lang.*;       //類別庫,常用,自動載入,可忽略
  2. import java.io.Console;  // 抓使用者key 鍵盤時會用到
  3. public class ch07//類別
  4. {
  5.   public static void main (String arg[]) //方法
  6.   {
  7.     Console cs=System.console();  //宣告cs
  8.     int score;
  9.     System.out.print("請輸入你的分數 :");
  10.     score=Integer.parseInt(cs.readLine());
  11.     if (score>=60)
  12.     {
  13.     System.out.print("恭喜你及格囉!");

  14.     }else
  15.      {
  16.     System.out.print("下次再加油 好嗎?");

  17.      }

  18.   }
  19. }
複製代碼

TOP

  1. import java.io.Console;
  2. public class ch07
  3. {
  4.    public static void main (String showdemo[])
  5.    {
  6.     Console console=System.console();
  7.     int score;
  8.     System.out.print("Please input your score =");
  9.     score=Integer.parseInt(console.readLine());

  10.     if(score >=60)
  11.     {
  12.       System.out.println("恭喜及格了");
  13.     }
  14.     else
  15.     {
  16.       System.out.println("成績不及格");
  17.     }

  18.    }
  19. }
複製代碼

TOP

回復 1# tonyh
  1. import java.io.Console;
  2. public class ch07
  3. {
  4.   public static void main(String args[])
  5.   {
  6.     Console keyin=System.console();
  7.     int int1;
  8.     Float ft2;
  9.     System.out.print("請你的成績:");
  10.     int1=Integer.parseInt(keyin.readLine());
  11.     if (int1>60)
  12.     {
  13.     System.out.print("恭喜您及格了!");
  14.     }else
  15.     {


  16.     System.out.print("恭喜您重修了!");


  17.     }

  18.   }
  19. }
複製代碼

TOP

返回列表