抽奖系统小项目

自己第一次写的小项目。。。

/**
 * @author XxxHuu
 */
package org.lanqiao;

import java.util.Scanner;

public class Lottery {
	static Scanner input = new Scanner(System.in);
	static String[] names = new String[100];
	static String[] passWord = new String[100];
	static int count = 0;
	static int count1 = 0;
	static int[] id = new int[10];
	static int[] num = new int[10];
	static String chooseYN = "y";

	public static void main(String[] args) {
		//生成5个幸运数字
		for (int i = 0; i < 5; i++) {
			num[count1] = (int) ((Math.random() * (9000)+1000));
			count1++;
		}
		while (true) {

			// 初始菜单
			System.out.println("*****欢迎进入奖课富翁系统*****");
			System.out.println("                      1、注册                        ");
			System.out.println("                      2、登录                        ");
			System.out.println("                      3、抽奖                        ");
			System.out.println("*********************************");
			System.out.println("请选择菜单");
			int choose = input.nextInt();
			switch (choose) {
			case 1:
				zhuCe();
				break;
			case 2:
				dengLu();
				break;
			case 3:
				chouJiang();
				break;

			default:
				System.out.println("您输入有误!");
				break;
			}
			System.out.println("继续输入吗?(y/n)");
			if (!isContinue()) {
				System.out.println("已退出,谢谢使用!");
				break;
			}
		}
	}

	public static void zhuCe() {

		// 注册
		System.out.println("【奖客富翁系统>注册】");
		System.out.println("请输入个人注册信息");
		System.out.println("用户名:");
		names[count] = input.next();
		System.out.println("密码:");
		passWord[count] = input.next();
		// 随机数产生
		int num1 = (int) ((Math.random() * (9000)+1000)); // *10000就是产生四位数
		System.out.println(num1);
		id[count] = num1;
		System.out.println("注册成功,请记好你的账号密码以及会员卡号!");
		System.out.println("用户名  " + names[count] + "  密码  " + passWord[count] + "  会员卡号  " + id[count]);
		count++;
		System.out.println();
	}

	public static void dengLu() {
		// 登录
		System.out.println("【奖客富翁系统>登录】");
		System.out.println("用户名:");
		String name = input.next();
		System.out.println("密码:");
		String passWord1 = input.next();
		for (int i = 0; i < names.length; i++) {
			if (name.equals(names[i]) && passWord1 == passWord[i]) {
				System.out.println("欢迎您!" + names[i]);
			}
		}
		System.out.println("会员卡号:  " + id[count - 1]);
	}

	
	public static void chouJiang() {
		System.out.println("【奖客富翁系统>抽奖】");
		System.out.println("系统此次的幸运数字:");
		for (int i = 0; i < 5; i++) {
			System.out.print(num[i] + "  ");
		}
		System.out.println("您的卡号为" + id[count - 1]);
		for (int j = 0; j < 5; j++) {
			if (num[j] == id[count - 1]) {
				System.out.println("恭喜您中奖了!");
				break;
			}
		}
	}

	public static boolean isContinue() {
		chooseYN = input.next();
		if (chooseYN.equalsIgnoreCase("n")) {
			return false;
		}
		return true;

	}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值