標題:
電子摸彩系統
[打印本頁]
作者:
tonyh
時間:
2017-3-31 21:17
標題:
電子摸彩系統
[attach]2113[/attach]
作者:
李知易
時間:
2017-4-7 19:12
import java.util.Scanner;
public class lotto
{
static Scanner s=new Scanner(System.in);
public static void main(String args[])
{
String student[]={"001 林屁孩","002 江屁孩","003 李小子","004 李陰納","005 黃種人","006 賴蛤罵","007 郭小孩","008 馬上好","009 蔣陰納","010 陳陰納","0411 陳屁孩","012 王屁孩"};
while(true)
{
System.out.println("\n☆★☆ 電子摸彩系統 v1.0 ☆★☆\n");
System.out.println("<主選單> 1-顯示所有彩卷 2-開始摸彩 3-結束\n");
int opt;
System.out.print("請選擇1~3: ");
opt=s.nextInt();
if(opt==3)
break;
if(opt==1)
{
System.out.println("\nNO name NO name");
System.out.println("======================");
if(student.length%2==0)
{
for(int i=0; i<student.length; i+=2)
{
System.out.println(student[i]+" "+student[i+1]);
}
}else
{
for(int i=0; i<student.length-2; i+=2)
{
System.out.println(student[i]+" "+student[i+1]);
}
System.out.println(student[student.length-1]);
}
System.out.println("======================");
System.out.println("共計"+student.length+"人");
continue;
}
if(opt==2)
{
int a;
System.out.print("\n請問要抽出幾位幸運兒(可以獲得禮券喔~): ");
a=s.nextInt();
int num[]=new int[a];
int i=0;
do
{
num[i]=(int)(Math.random()*student.length);
for(int j=0; j<i; j++)
{
if(num[i]==num[j])
{
i--;
break;
}
}
i++;
}while(i<a);
System.out.println();
for(i=0; i<a; i++)
{
System.out.println("第"+(i+1)+"位幸運兒(可以獲得禮券喔~)是: "+student[num[i]]);
new Scanner(System.in).nextLine();
}
System.out.println("<中獎名單>");
System.out.println("\nNO name NO name");
System.out.println("======================");
if(a%2==0)
{
for(i=0; i<a; i+=2)
{
System.out.println(student[num[i]]+" "+student[num[i+1]]);
}
}else
{
for(i=0; i<a-2; i+=2)
{
System.out.println(student[num[i]]+" "+student[num[i+1]]);
}
System.out.println(student[num[a-1]]);
}
System.out.println("======================");
System.out.println("恭喜以上"+a+"位同學可以獲得禮券!");
break;
}
}
}
}
複製代碼
作者:
陳思惟
時間:
2017-4-7 19:53
import java.util.Scanner;
public class lotto2016
{
static Scanner s=new Scanner(System.in);
public static void main(String args[])
{
String student[]={"001 甲
",
"009 乙
",
"011 丙
","012 丁
",
"016 戊
","017 己
","018 庚
","019 辛
","020 壬
",
"025 癸
"};
while(true)
{
System.out.println("\n☆★☆ 電子摸彩系統 v1.0 ☆★☆\n");
System.out.println("<主選單> 1-顯示所有彩卷 2-開始摸彩 3-結束\n");
int option;
System.out.print("在此輸入: ");
option=s.nextInt();
if(option==3)
break;
if(option==1)
{
System.out.println("\nNO 姓名 NO 姓名");
System.out.println("======================");
if(student.length%2==0)
{
for(int i=0; i<student.length; i+=2)
{
System.out.println(student[i]+" "+student[i+1]);
}
}else
{
for(int i=0; i<student.length-2; i+=2)
{
System.out.println(student[i]+" "+student[i+1]);
}
System.out.println(student[student.length-1]);
}
System.out.println("======================");
System.out.println("共計"+student.length+"人");
continue;
}
if(option==2)
{
int a;
System.out.print("\n請問要抽出幾位幸運兒? ");
a=s.nextInt();
int num[]=new int[a];
int i=0;
do
{
num[i]=(int)(Math.random()*student.length);
for(int j=0; j<i; j++)
{
if(num[i]==num[j])
{
i--;
break;
}
}
i++;
}while(i<a);
System.out.println();
for(i=0; i<a; i++)
{
System.out.println("第"+(i+1)+"位幸運兒是: "+student[num[i]]);
new Scanner(System.in).nextLine();
}
System.out.println("<中獎名單>");
System.out.println("\nNO 姓名 NO 姓名");
System.out.println("======================");
if(a%2==0)
{
for(i=0; i<a; i+=2)
{
System.out.println(student[num[i]]+" "+student[num[i+1]]);
}
}else
{
for(i=0; i<a-2; i+=2)
{
System.out.println(student[num[i]]+" "+student[num[i+1]]);
}
System.out.println(student[num[a-1]]);
}
System.out.println("======================");
System.out.println("恭喜以上"+a+"位同學!");
break;
}
}
}
}
複製代碼
作者:
黃璽安
時間:
2017-4-7 20:15
import java.util.Scanner;
public class Desktop{
static Scanner s=new Scanner(System.in);
public static void main(String args[])
{
String student[]={"001 吳世芳",
"009 黃詠軒",
"011 徐子翔","012 李娟洪",
"016 123","017 456","018 789","019 000","020 111",
"025 222",
"027 333","028 444","030 555"};
while(true)
{
System.out.println("\n☆★☆ 電子摸彩系統 v1.0 ☆★☆\n");
System.out.println("<主選單> 1-顯示所有彩卷 2-開始摸彩 3-結束\n");
int option;
System.out.print("在此輸入: ");
option=s.nextInt();
if(option==3)
break;
if(option==1)
{
System.out.println("\nNO 姓名 NO 姓名");
System.out.println("======================");
if(student.length%2==0)
{
for(int i=0; i<student.length; i+=2)
{
System.out.println(student[i]+" "+student[i+1]);
}
}else
{
for(int i=0; i<student.length-2; i+=2)
{
System.out.println(student[i]+" "+student[i+1]);
}
System.out.println(student[student.length-1]);
}
System.out.println("======================");
System.out.println("共計"+student.length+"人");
continue;
}
if(option==2)
{
int a;
System.out.print("\n請問要抽出幾位幸運兒? ");
a=s.nextInt();
int num[]=new int[a];
int i=0;
do
{
num[i]=(int)(Math.random()*student.length);
for(int j=0; j<i; j++)
{
if(num[i]==num[j])
{
i--;
break;
}
}
i++;
}while(i<a);
System.out.println();
for(i=0; i<a; i++)
{
System.out.println("第"+(i+1)+"位幸運兒是: "+student[num[i]]);
new Scanner(System.in).nextLine();
}
System.out.println("<中獎名單>");
System.out.println("\nNO 姓名 NO 姓名");
System.out.println("======================");
if(a%2==0)
{
for(i=0; i<a; i+=2)
{
System.out.println(student[num[i]]+" "+student[num[i+1]]);
}
}else
{
for(i=0; i<a-2; i+=2)
{
System.out.println(student[num[i]]+" "+student[num[i+1]]);
}
System.out.println(student[num[a-1]]);
}
System.out.println("======================");
System.out.println("恭喜以上"+a+"位同學!");
break;
}
}
}
}
複製代碼
作者:
曾挺桂
時間:
2017-4-7 20:15
本帖最後由 曾挺桂 於 2017-4-7 20:21 編輯
import java.util.Scanner;
public class lotto
{
static Scanner s=new Scanner(System.in);
public static void main(String args[])
{
String student[]={"001 翔王","002 猶太人","003 翔王之劍","004 翔王發射器","005 中國狗","006 安戈洛的翔王","007 凹進去的人","008 渣渣","009 本來凹進去的人","010 雙鵰者","0411 騎天宰龍記","012 傻逼"};
while(true)
{
System.out.println("\n☆★☆ 電子摸彩系統 v1.0 ☆★☆\n");
System.out.println("<主選單> 1-顯示所有機彩卷 2-開始摸彩 3-結束\n");
int opt;
System.out.print("給我選擇1~3: ");
opt=s.nextInt();
if(opt==3)
break;
if(opt==1)
{
System.out.println("\nNO name NO name");
System.out.println("======================");
if(student.length%2==0)
{
for(int i=0; i<student.length; i+=2)
{
System.out.println(student[i]+" "+student[i+1]);
}
}else
{
for(int i=0; i<student.length-2; i+=2)
{
System.out.println(student[i]+" "+student[i+1]);
}
System.out.println(student[student.length-1]);
}
System.out.println("======================");
System.out.println("共計"+student.length+"人");
continue;
}
if(opt==2)
{
int a;
System.out.print("\n請問要抽出幾位龜兒: ");
a=s.nextInt();
int num[]=new int[a];
int i=0;
do
{
num[i]=(int)(Math.random()*student.length);
for(int j=0; j<i; j++)
{
if(num[i]==num[j])
{
i--;
break;
}
}
i++;
}while(i<a);
System.out.println();
for(i=0; i<a; i++)
{
System.out.println("第"+(i+1)+"位龜兒是: "+student[num[i]]);
new Scanner(System.in).nextLine();
}
System.out.println("<中獎名單>");
System.out.println("\nNO name NO name");
System.out.println("======================");
if(a%2==0)
{
for(i=0; i<a; i+=2)
{
System.out.println(student[num[i]]+" "+student[num[i+1]]);
}
}else
{
for(i=0; i<a-2; i+=2)
{
System.out.println(student[num[i]]+" "+student[num[i+1]]);
}
System.out.println(student[num[a-1]]);
}
System.out.println("======================");
System.out.println("恭喜以上"+a+"位BL可以獲得禮券!");
break;
}
}
}
}
複製代碼
作者:
洪振庭
時間:
2017-4-7 20:28
import java.util.Scanner;
public class Ch22
{
static Scanner s=new Scanner(System.in);
public static void main(String args[])
{
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"};
while(true)
{
System.out.println("\n☆★☆ 電子摸彩系統 v1.0 ☆★☆\n");
System.out.println("<主選單> 1-顯示所有機彩卷 2-開始摸彩 3-結束\n");
int opt;
System.out.print("給選擇1~3: ");
opt=s.nextInt();
if(opt==3)
break;
if(opt==1)
{
System.out.println("\nNO 名紙 NO 名紙");
System.out.println("======================");
if(student.length%2==0)
{
for(int i=0; i<student.length; i+=2)
{
System.out.println(student[i]+" "+student[i+1]);
}
}else
{
for(int i=0; i<student.length-2; i+=2)
{
System.out.println(student[i]+" "+student[i+1]);
}
System.out.println(student[student.length-1]);
}
System.out.println("======================");
System.out.println("共計"+student.length+"人");
continue;
}
if(opt==2)
{
int a;
System.out.print("\n請問要抽出幾位仁兄: ");
a=s.nextInt();
int num[]=new int[a];
int i=0;
do
{
num[i]=(int)(Math.random()*student.length);
for(int j=0; j<i; j++)
{
if(num[i]==num[j])
{
i--;
break;
}
}
i++;
}while(i<a);
System.out.println();
for(i=0; i<a; i++)
{
System.out.println("第"+(i+1)+"位仁兄是: "+student[num[i]]);
new Scanner(System.in).nextLine();
}
System.out.println("<中獎名單>");
System.out.println("\nNO 名紙 NO 名紙");
System.out.println("======================");
if(a%2==0)
{
for(i=0; i<a; i+=2)
{
System.out.println(student[num[i]]+" "+student[num[i+1]]);
}
}else
{
for(i=0; i<a-2; i+=2)
{
System.out.println(student[num[i]]+" "+student[num[i+1]]);
}
System.out.println(student[num[a-1]]);
}
System.out.println("======================");
System.out.println("恭喜以上"+a+"位同學可以獲得數學考卷!");
break;
}
}
}
}
複製代碼
作者:
沈子耕
時間:
2017-4-7 20:44
package lotto;
import java.util.*;
public class lotto {
public static Scanner sc=new Scanner(System.in);
public static void main(String[] args) {
String stu[]={"001 王小明","002 林大同","003 陳小華","004 小屁孩","005 沈子耕","006 王怡君"
,"007 廖婷婷","008 蔡一零","009 林智零","010 王立紅","011 羅自祥","012 陳思維"};
while(true){
System.out.println("\n☆★☆ 電子摸彩系統 v1.0 ☆★☆\n");
System.out.println("<主選單> 1-顯示所有彩券 2-開始摸彩 3-結束");
int option;
option=sc.nextInt();
if(option==3)
break;
switch(option){
case 1:
System.out.println("\nNo name\tNo name");
System.out.println("========================");
if(stu.length%2==0){
for(int i=0; i<stu.length; i+=2)
System.out.println(stu[i]+"\t"+stu[i+1]);
}
else{
for(int i=0; i<stu.length-2; i+=2)
System.out.println(stu[i]+"\t"+stu[i+1]);
System.out.println(stu[stu.length-2]);
}
System.out.println("========================");
System.out.println("共計"+stu.length+"人");
break;
case 2:
int a;
System.out.println("\n請問要抽出幾位幸運兒: ");
a=sc.nextInt();
int num[]=new int[a];
int i=0;
do{
num[i]=(int)(Math.random()*stu.length);
for(int j=0; j<i; j++){
if(num[i]==num[j]){
i--;
break;
}
}
i++;
}while(i<a);
System.out.println();
for(i=0; i<a; i++){
System.out.println("第"+(i+1)+"位幸運兒是: "+stu[num[i]]);
new Scanner(System.in).nextLine();
}
System.out.println("\n<中獎名單>");
System.out.println("\nNo name\tNo name");
System.out.println("========================");
if(a%2==0){
for(int j=0; j<a; j+=2)
System.out.println(stu[num[j]]+"\t"+stu[num[j+1]]);
}
else{
for(int j=0; j<a-2; j+=2)
System.out.println(stu[num[j]]+"\t"+stu[num[j+1]]);
System.out.println(stu[num[a-1]]);
}
System.out.println("========================");
System.out.println("恭喜以上"+a+"位同學!");
break;
default:
continue;
}
}
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2