189 8069 5689

java幸运抽奖系统的方法-创新互联

创新互联www.cdcxhl.cn八线动态BGP香港云服务器提供商,新人活动买多久送多久,划算不套路!

创新互联公司2013年成立,是专业互联网技术服务公司,拥有项目网站设计、网站建设网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元龙川做网站,已为上家服务,为龙川各地企业和个人服务,联系电话:028-86922220

小编给大家分享一下java幸运抽奖系统的方法,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!

import java.util.Scanner;

public class luckyDraw {
 public static void main(String[] args) {
 String option;
 String username = "";
 int password = 0;
 int cardNumber = 0;
 int max = 9999;
 int mix = 1000;
 do {
  System.out.println("********欢迎进入奖客富翁系统********");
  System.out.println("\t1.注册");
  System.out.println("\t2.登录");
  System.out.println("\t3.抽奖");
  System.out.println("*******************************");
  Scanner in = new Scanner(System.in);
  System.out.print("请选择菜单:");
  int num = in.nextInt();
  switch(num) {
  case 1:
  System.out.println("[奖客富翁系统 > 注册]");
  System.out.println("请填写个人注册信息:");
  System.out.print("用户名:");
  username = in.next();
  System.out.print("密码:");
  password = in.nextInt();
  cardNumber = (int)(Math.random()*(max-mix))+mix;
  System.out.println();
  System.out.println("注册成功,请记好您的会员卡号");
  System.out.println("用户名\t密码\t会员卡号");
  System.out.println(username+"\t"+password+"\t"+cardNumber);  
  break;
  case 2:
   for (int i = 1; i < 4; i++) {    
   System.out.println("[奖客富翁系统 > 登录]");
   System.out.print("请输入用户名:");
   String username1 = in.next();
   System.out.print("请输入密码:");
   int password1 = in.nextInt();
   if ((username1.equals(username))&(password1==password)) {
   System.out.println("欢迎您:"+username);
   break;
   } else {
   System.out.println("用户名或密码错误!请重新输入(最多3次机会,当前第"+i+"次)!");
   }
   }
  break;
  case 3:
  System.out.println("[奖客富翁系统 > 抽奖]");
  for(int i = 1;i < 4;i++) {
  System.out.print("请输入您的卡号:");
  int cardNumber1 = in.nextInt();
  if(cardNumber1==cardNumber) {
   int luckynumber1 = (int)(Math.random()*(max-mix))+mix;
   int luckynumber2 = (int)(Math.random()*(max-mix))+mix;
   int luckynumber3 = (int)(Math.random()*(max-mix))+mix;
   int luckynumber4 = (int)(Math.random()*(max-mix))+mix;
   int luckynumber5 = (int)(Math.random()*(max-mix))+mix;
   System.out.println();
   System.out.println("本日的幸运数字为:"+luckynumber1+" "+luckynumber2+" "+luckynumber3+" "+luckynumber4+" "+luckynumber5);
   if ((cardNumber1==luckynumber1)||(cardNumber1==luckynumber2)||(cardNumber1==luckynumber3)||(cardNumber1==luckynumber4)||(cardNumber1==luckynumber5)) {
   System.out.println("恭喜!您是本日的幸运会员!");   
   } else {
   System.out.println("抱歉!您不是本日的幸运会员!");
   }
   break;
  }else {
   System.out.println("会员卡号不正确,您还有"+(3-i)+"次机会!");
  }
  }  
  break;
  default:
  System.out.println("您的输入有误!");
  }
  System.out.print("继续吗?(y/n):");
  option = in.next();
  System.out.println();
 } while ("y".equals(option));
 System.out.println("系统退出,谢谢使用!");
 }
}

分享名称:java幸运抽奖系统的方法-创新互联
文章路径:http://cdxtjz.cn/article/hcgdd.html

其他资讯