Lottery system based on Java and Lucky Draw System Based on Java

Source: Internet
Author: User
Tags bit set

Lottery system based on Java and Lucky Draw System Based on Java

This task requires the development of a lucky draw system for a mall. The customer must first register as a member of the mall. After Successful Logon, the member can participate in the lucky draw.

Register

Select the "register" menu to go to the registration page. After entering the user name and password, the system prompts that the registration is successful and the membership card number is given.

Login

After successful registration, select the "Logon" menu to go To the logon page. Enter the user name and password for registration. Login successful. The system prompts the welcome information. If the user and password are incorrectly entered, the system prompts the user to continue entering the password. A maximum of three opportunities are allowed.

Lucky Draw

After logon, select the lucky draw menu to go to the lucky draw page. Enter the membership card number, and the system generates 5 4-digit random numbers as lucky numbers. If the member card number is one of them, it becomes a lucky member of the current day.

Source code

Package cn. jbit. dlc1; import java. util. secret; public class LuckyNumber5 {/*** Lucky Draw */public static void main (String [] args) {String answer = "y "; // identify whether to continue String userName = ""; // userName String password = ""; // password int cardNumber = 0; // card number boolean isRegister = false; // identify whether to register boolean isLogin = false; // identify whether to log on to int max = 9999; int min = 1000; login input = new Login (System. in); do {System. o Ut. println ("****** welcome to the rewards guest monopoly System ******"); System. out. println ("\ t1. register"); System. out. println ("\ t2. login"); System. out. println ("\ t3. lottery"); System. out. println ("***************************"); System. out. print ("Select menu:"); int choice = input. nextInt (); switch (choice) {case 1: System. out. println ("[rewards guest monopoly System> Registration]"); System. out. println ("Enter Your Personal Registration Information:"); System. out. print ("userName:"); userName = input. next (); System. out. print ("Password:"); password = input. next (); // obtain a four-digit random number as the card number cardNumber = (int) (Math. random () * (max-min) + min; System. out. println ("\ n registration successful, please remember your membership card number"); System. out. println ("USERNAME \ t password \ t membership card number"); System. out. println (userName + "\ t" + password + "\ t" + cardNumber); isRegister = true; // registration successful, flag bit set to true break; case 2: System. out. println ("[rewards guest monopoly system> Login]"); if (isRegister) {// determines whether to register/3 input opportunities for (int I = 1; I <= 3; I ++ ){ System. out. print ("Enter the User name:"); String inputName = input. next (); System. out. print ("Enter Password:"); String inputPassword = input. next (); if (userName. equals (inputName) & password. equals (inputPassword) {System. out. println ("\ n welcome:" + userName); isLogin = true; // login successful, flag set to true break;} else if (I <3) {System. out. println ("incorrect user name or password, and" + (3-I) +! ");} Else {System. out. println (" You entered an error three times! ") ;}} Else {System. out. println (" Please register and log on again! ");} Break; case 3: System. out. println (" [prize winner System> Lottery] "); if (! IsLogin) {// determine whether to log on to System. out. println ("Please log on first before drawing! "); System. out. println (" continue? (Y/n) "); answer = input. next ();} else {// generates 5 4-digit random numbers and stores them in the array int [] luckynums = new int [5]; for (int I = 0; I <luckynums. length; I ++) {luckynums [I] = (int) (Math. random () * (max-min) + min;} System. out. print ("Enter your card number:"); int yourcard = input. nextInt (); int I; System. out. print ("\ n the lucky number for this day is:"); for (I = 0; I <luckynums. length; I ++) {System. out. print (luckynums [I] + "") ;}for (I = 0; I <luckynums. leng Th; I ++) {if (luckynums [I] = yourcard) {System. out. println ("\ n congratulations! You are a lucky member of this day! "); Break ;}}if (I = luckynums. length) {System. out. println (" \ n sorry! You are not a lucky member of this day! ") ;}} Break; default: System. out. println (" [your input is incorrect.] "); Break;} System. out. print (" continue? (Y/n): "); answer = input. next (); System. out. println ("");} while ("y ". equals (answer); if ("n ". equals (answer) {System. out. println ("the system exits. Thank you! ");}}}

It's just a basic small architecture, and there are still many things that can be improved, so I hope to help you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.