返回列表 發帖

if...else 判斷式

判斷年齡~~是否可以考駕照
  1. import java.util.Scanner;
  2. public class Ch08
  3. {
  4.     public static void main(String args[])
  5.     {
  6.          Scanner c= new Scanner(System.in);
  7.          int age;
  8.          System.out.print("輸入年紀: ");
  9.          age=Integer.parseInt(c.nextLine());
  10.          if(age>=18)
  11.              System.out.println("可以考駕照了!");
  12.          else
  13.              System.out.println("再等等~~");
  14.     }
  15. }
複製代碼

  1. import java.util.Scanner;


  2. public class Aa {

  3.         public static void main(String[] args) {
  4.                 // TODO 自動產生的方法 Stub
  5.                 Scanner c = new Scanner(System.in);
  6.                 int a;
  7.                 System.out.print("請輸入年紀:");
  8.                 a = Integer.parseInt(c.nextLine());
  9.                 if(a>=18)
  10.                         System.out.print("可以考駕照了!");
  11.                 else
  12.                         System.out.print("未成年不可以考駕照!");

  13.         }

  14. }
複製代碼

TOP

  1. import java.util.Scanner;
  2. public class ccc {

  3.         public static void main(String[] args) {
  4.                 // TODO 自動產生的方法 Stub
  5.                 int y;
  6.                 Scanner c =new Scanner(System.in);
  7.                 System.out.println("請輸入年齡");
  8.                 y=c.nextInt();
  9.                 if(y>=18)
  10.                 {
  11.                         System.out.print("可以考駕照");
  12.                 }
  13.                 else
  14.                 {
  15.                         System.out.print("不能考駕照");
  16.                 }
  17.         }

  18. }
複製代碼

TOP

  1. import java.util.Scanner;
  2. public class test {

  3.         public static void main(String[] args) {
  4.                 // TODO 自動產生的方法 Stub
  5.                 Scanner a=new Scanner(System.in);
  6.                 int age;
  7.                 System.out.print("請輸入你的年齡:");
  8.                 age = Integer.parseInt(a.nextLine());
  9.                 if(age>=18)
  10.                         System.out.println("可以考駕照了!");
  11.                 else
  12.                         System.out.println("還不行喔~");
  13.         }
  14. }
複製代碼

TOP

  1. import java.util.Scanner;


  2. public class World {

  3.         public static void main(String[] args) {
  4.                 // TODO 自動產生的方法 Stub

  5.                 int age;
  6.                 Scanner c=new Scanner(System.in);
  7.                 System.out.println("請輸入年齡:");
  8.                 age=c.nextInt();
  9.                 if(age>=18)
  10.                         System.out.println("可以考駕照了!");
  11.                 else
  12.                         System.out.println("再等等~~");
  13.         }

  14. }
複製代碼

TOP

  1. public class JAVA02 {
  2.           
  3.     public static void main(String args[])
  4. {
  5.         Scanner c= new Scanner(System.in);
  6.       
  7.         int age;
  8.     System.out.print("請輸入年紀");
  9.     age = Integer.parseInt(c.nextLine()) ;

  10.       
  11.       
  12.      if(age >= 18 )  
  13.       
  14.        {
  15.               System.out.print("可以考了");
  16.        }
  17.      else {
  18.              
  19.                 System.out.print("還不行考");
  20.      }
  21.       


  22.       
  23.   }
  24. }
複製代碼

TOP

  1. package haha;

  2. import java.util.Scanner;

  3. public class haha {

  4.         public static void main(String[] args) {
  5.         Scanner c=new Scanner(System.in);
  6.         int age;
  7.         System.out.print("請輸入年紀: ");
  8.         age=Integer.parseInt(c.nextLine());
  9.         if(age>=18)
  10.                 System.out.println("可以考駕照了!!!");
  11.         else
  12.                 System.out.println("在等等!!!");
  13.         }

  14. }
複製代碼

TOP

  1. import java.util.Scanner;
  2. public class D0601 {

  3.         public static void main(String[] args) {
  4.                 // TODO 自動產生的方法 Stub
  5.            int age;
  6.            Scanner c=new Scanner(System.in);
  7.            System.out.print("請輸入年紀:");
  8.            age=Integer.parseInt(c.nextLine());
  9.            if(age>=18)
  10.            {
  11.                    System.out.print("准考駕照");
  12.            }else
  13.            {
  14.                    System.out.print("你這個屁孩,滾吧");
  15.            }
  16.         }

  17. }
複製代碼

TOP

  1. import java.util.Scanner;
  2. public class Gg {

  3.         public static void main(String[] args) {
  4.                 // TODO 自動產生的方法 Stub
  5.             Scanner c= new Scanner(System.in);
  6.             int age;
  7.             System.out.print("輸入年紀: ");
  8.             age=Integer.parseInt(c.nextLine());
  9.             if(age>=18)
  10.                 System.out.println("老司機,可以考駕照了!");
  11.             else
  12.                 System.out.println("菜鳥,再等等~~");
  13.         }

  14. }
複製代碼

TOP

  1. package hallo;
  2. import java.util.Scanner;

  3. public class hihi {

  4.         public static void main(String[] args) {
  5.                 // TODO 自動產生的方法 Stub
  6.         Scanner c=new Scanner(System.in);
  7.         int age;
  8.         System.out.print("輸入年紀: ");
  9.         age=Integer.parseInt(c.nextLine());
  10.         if(age>=18)
  11.                 System.out.print("可以考駕照囉~");
  12.         else
  13.                 System.out.println("年齡還夠喔~");
  14.         }

  15. }
複製代碼

TOP

  1. import java.util.Scanner;
  2. public class Hello {

  3.         public static void main(String[] args) {
  4.                 // TODO 自動產生的方法 Stub
  5.                 Scanner c= new Scanner(System.in);
  6.         int age;
  7.         System.out.print("輸入年紀: ");
  8.         age=Integer.parseInt(c.nextLine());
  9.         if(age>=18)
  10.             System.out.println("可以考駕照了!");
  11.         else
  12.             System.out.println("你未滿十八歲,無法取得駕照");
  13.         }

  14. }
複製代碼

TOP

返回列表