返回列表 發帖

電子摸彩系統

附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

  1. import java.util.Scanner;
  2. public class lotto
  3. {
  4.     static Scanner s=new Scanner(System.in);
  5.         public static void main(String args[])
  6.     {
  7.         
  8.         String student[]={"001 林屁孩","002 江屁孩","003 李小子","004 李陰納","005 黃種人","006 賴蛤罵","007 郭小孩","008 馬上好","009 蔣陰納","010 陳陰納","0411 陳屁孩","012 王屁孩"};
  9.         while(true)
  10.         {
  11.             System.out.println("\n☆★☆ 電子摸彩系統 v1.0 ☆★☆\n");
  12.             System.out.println("<主選單> 1-顯示所有彩卷 2-開始摸彩 3-結束\n");
  13.             int opt;
  14.             System.out.print("請選擇1~3: ");
  15.             opt=s.nextInt();
  16.             
  17.             if(opt==3)
  18.                 break;

  19.             if(opt==1)
  20.             {
  21.                 System.out.println("\nNO  name  NO  name");
  22.                 System.out.println("======================");
  23.                 if(student.length%2==0)
  24.                 {
  25.                     for(int i=0; i<student.length; i+=2)
  26.                     {
  27.                         System.out.println(student[i]+"        "+student[i+1]);
  28.                     }
  29.                 }else
  30.                 {
  31.                     for(int i=0; i<student.length-2; i+=2)
  32.                     {
  33.                         System.out.println(student[i]+"        "+student[i+1]);
  34.                     }
  35.                     System.out.println(student[student.length-1]);
  36.                 }
  37.                 System.out.println("======================");
  38.                 System.out.println("共計"+student.length+"人");
  39.                 continue;
  40.             }

  41.             if(opt==2)
  42.             {
  43.                 int a;
  44.                 System.out.print("\n請問要抽出幾位幸運兒(可以獲得禮券喔~): ");
  45.                 a=s.nextInt();
  46.                 int num[]=new int[a];
  47.                 int i=0;
  48.                 do
  49.                 {
  50.                     num[i]=(int)(Math.random()*student.length);
  51.                     for(int j=0; j<i; j++)
  52.                     {
  53.                          if(num[i]==num[j])
  54.                          {
  55.                            i--;
  56.                            break;
  57.                          }
  58.                     }
  59.                     i++;
  60.                 }while(i<a);
  61.                 System.out.println();
  62.                 for(i=0; i<a; i++)
  63.                 {
  64.                     System.out.println("第"+(i+1)+"位幸運兒(可以獲得禮券喔~)是: "+student[num[i]]);  
  65.                     new Scanner(System.in).nextLine();
  66.                 }
  67.                 System.out.println("<中獎名單>");
  68.                 System.out.println("\nNO  name  NO  name");
  69.                 System.out.println("======================");
  70.                 if(a%2==0)
  71.                 {
  72.                     for(i=0; i<a; i+=2)
  73.                     {
  74.                         System.out.println(student[num[i]]+"        "+student[num[i+1]]);
  75.                     }
  76.                 }else
  77.                 {
  78.                     for(i=0; i<a-2; i+=2)
  79.                     {
  80.                         System.out.println(student[num[i]]+"        "+student[num[i+1]]);
  81.                     }
  82.                     System.out.println(student[num[a-1]]);
  83.                 }
  84.                 System.out.println("======================");
  85.                 System.out.println("恭喜以上"+a+"位同學可以獲得禮券!");
  86.                 break;
  87.             }
  88.         }
  89.     }
  90. }
複製代碼
EEEEEEEEEEEEELLLLLLLLLLLLLIIIIIIIIIIIII

TOP

  1. import java.util.Scanner;
  2. public class lotto2016
  3. {
  4.     static Scanner s=new Scanner(System.in);
  5.         public static void main(String args[])
  6.     {
  7.         
  8.         String student[]={"001 甲
  9. ",
  10.                           "009 乙
  11. ",
  12.                           "011 丙
  13. ","012 丁
  14. ",
  15.                           "016 戊

  16. ","017 己
  17. ","018 庚
  18. ","019 辛
  19. ","020 壬
  20. ",
  21.                           "025 癸
  22. "};
  23.         while(true)
  24.         {
  25.             System.out.println("\n☆★☆ 電子摸彩系統 v1.0 ☆★☆\n");
  26.             System.out.println("<主選單> 1-顯示所有彩卷 2-開始摸彩 3-結束\n");
  27.             int option;
  28.             System.out.print("在此輸入: ");
  29.             option=s.nextInt();
  30.             
  31.             if(option==3)
  32.                 break;

  33.             if(option==1)
  34.             {
  35.                 System.out.println("\nNO  姓名             NO  姓名");
  36.                 System.out.println("======================");
  37.                 if(student.length%2==0)
  38.                 {
  39.                     for(int i=0; i<student.length; i+=2)
  40.                     {
  41.                         System.out.println(student[i]+"        "+student[i+1]);
  42.                     }
  43.                 }else
  44.                 {
  45.                     for(int i=0; i<student.length-2; i+=2)
  46.                     {
  47.                         System.out.println(student[i]+"        "+student[i+1]);
  48.                     }
  49.                     System.out.println(student[student.length-1]);
  50.                 }
  51.                 System.out.println("======================");
  52.                 System.out.println("共計"+student.length+"人");
  53.                 continue;
  54.             }

  55.             if(option==2)
  56.             {
  57.                 int a;
  58.                 System.out.print("\n請問要抽出幾位幸運兒? ");
  59.                 a=s.nextInt();
  60.                 int num[]=new int[a];
  61.                 int i=0;
  62.                 do
  63.                 {
  64.                     num[i]=(int)(Math.random()*student.length);
  65.                     for(int j=0; j<i; j++)
  66.                     {
  67.                          if(num[i]==num[j])
  68.                          {
  69.                            i--;
  70.                            break;
  71.                          }
  72.                     }
  73.                     i++;
  74.                 }while(i<a);
  75.                 System.out.println();
  76.                 for(i=0; i<a; i++)
  77.                 {
  78.                     System.out.println("第"+(i+1)+"位幸運兒是: "+student[num[i]]);  
  79.                     new Scanner(System.in).nextLine();
  80.                 }
  81.                 System.out.println("<中獎名單>");
  82.                 System.out.println("\nNO  姓名           NO  姓名");
  83.                 System.out.println("======================");
  84.                 if(a%2==0)
  85.                 {
  86.                     for(i=0; i<a; i+=2)
  87.                     {
  88.                         System.out.println(student[num[i]]+"        "+student[num[i+1]]);
  89.                     }
  90.                 }else
  91.                 {
  92.                     for(i=0; i<a-2; i+=2)
  93.                     {
  94.                         System.out.println(student[num[i]]+"        "+student[num[i+1]]);
  95.                     }
  96.                     System.out.println(student[num[a-1]]);
  97.                 }
  98.                 System.out.println("======================");
  99.                 System.out.println("恭喜以上"+a+"位同學!");
  100.                 break;
  101.             }
  102.         }
  103.     }
  104. }
複製代碼

TOP

  1. import java.util.Scanner;
  2. public class Desktop{
  3.     static Scanner s=new Scanner(System.in);
  4.         public static void main(String args[])
  5.     {
  6.         
  7.         String student[]={"001 吳世芳",
  8.                                                   "009 黃詠軒",
  9.                                                   "011 徐子翔","012 李娟洪",
  10.                                                   "016 123","017 456","018 789","019 000","020 111",
  11.                                                   "025 222",
  12.                                                   "027 333","028 444","030 555"};
  13.         while(true)
  14.         {
  15.             System.out.println("\n☆★☆ 電子摸彩系統 v1.0 ☆★☆\n");
  16.             System.out.println("<主選單> 1-顯示所有彩卷 2-開始摸彩 3-結束\n");
  17.             int option;
  18.             System.out.print("在此輸入: ");
  19.             option=s.nextInt();
  20.             
  21.             if(option==3)
  22.                 break;

  23.             if(option==1)
  24.             {
  25.                 System.out.println("\nNO  姓名             NO  姓名");
  26.                 System.out.println("======================");
  27.                 if(student.length%2==0)
  28.                 {
  29.                     for(int i=0; i<student.length; i+=2)
  30.                     {
  31.                         System.out.println(student[i]+"        "+student[i+1]);
  32.                     }
  33.                 }else
  34.                 {
  35.                     for(int i=0; i<student.length-2; i+=2)
  36.                     {
  37.                         System.out.println(student[i]+"        "+student[i+1]);
  38.                     }
  39.                     System.out.println(student[student.length-1]);
  40.                 }
  41.                 System.out.println("======================");
  42.                 System.out.println("共計"+student.length+"人");
  43.                 continue;
  44.             }

  45.             if(option==2)
  46.             {
  47.                 int a;
  48.                 System.out.print("\n請問要抽出幾位幸運兒? ");
  49.                 a=s.nextInt();
  50.                 int num[]=new int[a];
  51.                 int i=0;
  52.                 do
  53.                 {
  54.                     num[i]=(int)(Math.random()*student.length);
  55.                     for(int j=0; j<i; j++)
  56.                     {
  57.                          if(num[i]==num[j])
  58.                          {
  59.                            i--;
  60.                            break;
  61.                          }
  62.                     }
  63.                     i++;
  64.                 }while(i<a);
  65.                 System.out.println();
  66.                 for(i=0; i<a; i++)
  67.                 {
  68.                     System.out.println("第"+(i+1)+"位幸運兒是: "+student[num[i]]);  
  69.                     new Scanner(System.in).nextLine();
  70.                 }
  71.                 System.out.println("<中獎名單>");
  72.                 System.out.println("\nNO  姓名           NO  姓名");
  73.                 System.out.println("======================");
  74.                 if(a%2==0)
  75.                 {
  76.                     for(i=0; i<a; i+=2)
  77.                     {
  78.                         System.out.println(student[num[i]]+"        "+student[num[i+1]]);
  79.                     }
  80.                 }else
  81.                 {
  82.                     for(i=0; i<a-2; i+=2)
  83.                     {
  84.                         System.out.println(student[num[i]]+"        "+student[num[i+1]]);
  85.                     }
  86.                     System.out.println(student[num[a-1]]);
  87.                 }
  88.                 System.out.println("======================");
  89.                 System.out.println("恭喜以上"+a+"位同學!");
  90.                 break;
  91.             }
  92.         }
  93.     }
  94. }
複製代碼

TOP

本帖最後由 曾挺桂 於 2017-4-7 20:21 編輯
  1. import java.util.Scanner;
  2. public class lotto
  3. {
  4.     static Scanner s=new Scanner(System.in);
  5.         public static void main(String args[])
  6.     {
  7.         
  8.         String student[]={"001 翔王","002 猶太人","003 翔王之劍","004 翔王發射器","005 中國狗","006 安戈洛的翔王","007 凹進去的人","008 渣渣","009 本來凹進去的人","010 雙鵰者","0411 騎天宰龍記","012 傻逼"};
  9.         while(true)
  10.         {
  11.             System.out.println("\n☆★☆ 電子摸彩系統 v1.0 ☆★☆\n");
  12.             System.out.println("<主選單> 1-顯示所有機彩卷 2-開始摸彩 3-結束\n");
  13.             int opt;
  14.             System.out.print("給我選擇1~3: ");
  15.             opt=s.nextInt();
  16.             
  17.             if(opt==3)
  18.                 break;

  19.             if(opt==1)
  20.             {
  21.                 System.out.println("\nNO  name  NO  name");
  22.                 System.out.println("======================");
  23.                 if(student.length%2==0)
  24.                 {
  25.                     for(int i=0; i<student.length; i+=2)
  26.                     {
  27.                         System.out.println(student[i]+"        "+student[i+1]);
  28.                     }
  29.                 }else
  30.                 {
  31.                     for(int i=0; i<student.length-2; i+=2)
  32.                     {
  33.                         System.out.println(student[i]+"        "+student[i+1]);
  34.                     }
  35.                     System.out.println(student[student.length-1]);
  36.                 }
  37.                 System.out.println("======================");
  38.                 System.out.println("共計"+student.length+"人");
  39.                 continue;
  40.             }

  41.             if(opt==2)
  42.             {
  43.                 int a;
  44.                 System.out.print("\n請問要抽出幾位龜兒: ");
  45.                 a=s.nextInt();
  46.                 int num[]=new int[a];
  47.                 int i=0;
  48.                 do
  49.                 {
  50.                     num[i]=(int)(Math.random()*student.length);
  51.                     for(int j=0; j<i; j++)
  52.                     {
  53.                          if(num[i]==num[j])
  54.                          {
  55.                            i--;
  56.                            break;
  57.                          }
  58.                     }
  59.                     i++;
  60.                 }while(i<a);
  61.                 System.out.println();
  62.                 for(i=0; i<a; i++)
  63.                 {
  64.                     System.out.println("第"+(i+1)+"位龜兒是: "+student[num[i]]);  
  65.                     new Scanner(System.in).nextLine();
  66.                 }
  67.                 System.out.println("<中獎名單>");
  68.                 System.out.println("\nNO  name  NO  name");
  69.                 System.out.println("======================");
  70.                 if(a%2==0)
  71.                 {
  72.                     for(i=0; i<a; i+=2)
  73.                     {
  74.                         System.out.println(student[num[i]]+"        "+student[num[i+1]]);
  75.                     }
  76.                 }else
  77.                 {
  78.                     for(i=0; i<a-2; i+=2)
  79.                     {
  80.                         System.out.println(student[num[i]]+"        "+student[num[i+1]]);
  81.                     }
  82.                     System.out.println(student[num[a-1]]);
  83.                 }
  84.                 System.out.println("======================");
  85.                 System.out.println("恭喜以上"+a+"位BL可以獲得禮券!");
  86.                 break;
  87.             }
  88.         }
  89.     }
  90. }
複製代碼

TOP

  1. import java.util.Scanner;
  2. public class Ch22
  3. {
  4.     static Scanner s=new Scanner(System.in);
  5.         public static void main(String args[])
  6.     {
  7.         
  8.         String student[]={"001 1","002 2","003 3","004 4","005 5","006 6","007 7","008 8","009 8","010 10","013 13","012 12"};
  9.         while(true)
  10.         {
  11.             System.out.println("\n☆★☆ 電子摸彩系統 v1.0 ☆★☆\n");
  12.             System.out.println("<主選單> 1-顯示所有機彩卷 2-開始摸彩 3-結束\n");
  13.             int opt;
  14.             System.out.print("給選擇1~3: ");
  15.             opt=s.nextInt();
  16.             
  17.             if(opt==3)
  18.                 break;

  19.             if(opt==1)
  20.             {
  21.                 System.out.println("\nNO  名紙               NO  名紙");
  22.                 System.out.println("======================");
  23.                 if(student.length%2==0)
  24.                 {
  25.                     for(int i=0; i<student.length; i+=2)
  26.                     {
  27.                         System.out.println(student[i]+"        "+student[i+1]);
  28.                     }
  29.                 }else
  30.                 {
  31.                     for(int i=0; i<student.length-2; i+=2)
  32.                     {
  33.                         System.out.println(student[i]+"        "+student[i+1]);
  34.                     }
  35.                     System.out.println(student[student.length-1]);
  36.                 }
  37.                 System.out.println("======================");
  38.                 System.out.println("共計"+student.length+"人");
  39.                 continue;
  40.             }

  41.             if(opt==2)
  42.             {
  43.                 int a;
  44.                 System.out.print("\n請問要抽出幾位仁兄: ");
  45.                 a=s.nextInt();
  46.                 int num[]=new int[a];
  47.                 int i=0;
  48.                 do
  49.                 {
  50.                     num[i]=(int)(Math.random()*student.length);
  51.                     for(int j=0; j<i; j++)
  52.                     {
  53.                          if(num[i]==num[j])
  54.                          {
  55.                            i--;
  56.                            break;
  57.                          }
  58.                     }
  59.                     i++;
  60.                 }while(i<a);
  61.                 System.out.println();
  62.                 for(i=0; i<a; i++)
  63.                 {
  64.                     System.out.println("第"+(i+1)+"位仁兄是: "+student[num[i]]);  
  65.                     new Scanner(System.in).nextLine();
  66.                 }
  67.                 System.out.println("<中獎名單>");
  68.                 System.out.println("\nNO  名紙                NO  名紙");
  69.                 System.out.println("======================");
  70.                 if(a%2==0)
  71.                 {
  72.                     for(i=0; i<a; i+=2)
  73.                     {
  74.                         System.out.println(student[num[i]]+"        "+student[num[i+1]]);
  75.                     }
  76.                 }else
  77.                 {
  78.                     for(i=0; i<a-2; i+=2)
  79.                     {
  80.                         System.out.println(student[num[i]]+"        "+student[num[i+1]]);
  81.                     }
  82.                     System.out.println(student[num[a-1]]);
  83.                 }
  84.                 System.out.println("======================");
  85.                 System.out.println("恭喜以上"+a+"位同學可以獲得數學考卷!");
  86.                 break;
  87.             }
  88.         }
  89.     }
  90. }
複製代碼

TOP

  1. package lotto;
  2. import java.util.*;
  3. public class lotto {
  4.         public static Scanner sc=new Scanner(System.in);
  5.         public static void main(String[] args) {
  6.                 String stu[]={"001 王小明","002 林大同","003 陳小華","004 小屁孩","005 沈子耕","006 王怡君"
  7.                                           ,"007 廖婷婷","008 蔡一零","009 林智零","010 王立紅","011 羅自祥","012 陳思維"};
  8.                 while(true){
  9.                         System.out.println("\n☆★☆ 電子摸彩系統 v1.0 ☆★☆\n");
  10.                         System.out.println("<主選單> 1-顯示所有彩券 2-開始摸彩 3-結束");
  11.                         int option;
  12.                         option=sc.nextInt();
  13.                         if(option==3)
  14.                                 break;
  15.                         switch(option){
  16.                                 case 1:
  17.                                         System.out.println("\nNo  name\tNo  name");
  18.                                         System.out.println("========================");
  19.                                         if(stu.length%2==0){
  20.                                                 for(int i=0; i<stu.length; i+=2)
  21.                                                         System.out.println(stu[i]+"\t"+stu[i+1]);
  22.                                         }
  23.                                         else{
  24.                                                 for(int i=0; i<stu.length-2; i+=2)
  25.                                                         System.out.println(stu[i]+"\t"+stu[i+1]);
  26.                                                 System.out.println(stu[stu.length-2]);
  27.                                         }
  28.                                         System.out.println("========================");
  29.                                         System.out.println("共計"+stu.length+"人");
  30.                                         break;
  31.                                 case 2:
  32.                                         int a;
  33.                                         System.out.println("\n請問要抽出幾位幸運兒: ");
  34.                                         a=sc.nextInt();
  35.                                         int num[]=new int[a];
  36.                                         int i=0;
  37.                                         do{
  38.                                                 num[i]=(int)(Math.random()*stu.length);
  39.                                                 for(int j=0; j<i; j++){
  40.                                                         if(num[i]==num[j]){
  41.                                                                 i--;
  42.                                                                 break;
  43.                                                         }
  44.                                                 }
  45.                                                 i++;
  46.                                         }while(i<a);
  47.                                         System.out.println();
  48.                                         for(i=0; i<a; i++){
  49.                                                 System.out.println("第"+(i+1)+"位幸運兒是: "+stu[num[i]]);
  50.                                                 new Scanner(System.in).nextLine();
  51.                                         }
  52.                                         System.out.println("\n<中獎名單>");
  53.                                         System.out.println("\nNo  name\tNo  name");
  54.                                         System.out.println("========================");
  55.                                         if(a%2==0){
  56.                                                 for(int j=0; j<a; j+=2)
  57.                                                         System.out.println(stu[num[j]]+"\t"+stu[num[j+1]]);
  58.                                         }
  59.                                         else{
  60.                                                 for(int j=0; j<a-2; j+=2)
  61.                                                         System.out.println(stu[num[j]]+"\t"+stu[num[j+1]]);
  62.                                                 System.out.println(stu[num[a-1]]);
  63.                                         }
  64.                                         System.out.println("========================");
  65.                                         System.out.println("恭喜以上"+a+"位同學!");
  66.                                         break;
  67.                                 default:
  68.                                         continue;
  69.                         }
  70.                 }
  71.                
  72.         }

  73. }
複製代碼
ABCDEFGHIJKLMNOPQRSTUVWXYZ

TOP

返回列表