Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

lottery JAVA program to simulate the lottery . In this game the player will pick four numbers (between 1 and 40 inclusive) and the computer

lottery JAVA program to simulate the lottery. In this game the player will pick four numbers (between 1 and 40 inclusive) and the computer will generate four random numbers (between 1 and 40 inclusive).

The specifications are as follows:

You must have a user defined classes within the code. Code done in only one main method will not be accepted!

The data structure you MUST use for the four player selected numbers is:

int[] player=new int[4] ;

The data structure you MUST use for the four computer generated numbers is:

int[] computer=new int[4];

Specifications of the project:

Create one new user defined class to contain all of the methods and all of the data

Create a method within the class to prompt the player to select 4 numbers between 1 and 40 inclusive

Create a method within the class to have the computer generate 4 random numbers between 1 and 40 inclusive

Create a method within the class to count how many of the players numbers matched the computers generated numbers

Create a method within the class to print the players numbers, the computer s numbers and the number of matches

Your code must run until the player wants to stop. You will ask the player if they want to play the lottery game again and then start another game (ask for new numbers etc) You must make sure the player can enter capital or lower case letters to allow the lottery game to be played again. For example, if you are asking the player to enter yes, your program must be user friendly and accept any combination of capital of lower case letters such as yes, YES, Yes, yES, yeS (hint: you could use a Java string function to change the input to all upper or lower case)

Additional Requirements:

All braces are to be on lines by themselves

The java base class and the main method in the java program is to be first in the code and your new class is to be AFTER the java base class (after the System.exit(0));

All data must be defined at the beginning of each method

You will have to investigate and implement code to:

Generate a random number between 1 and 40

Change upper case to lower case etc

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

4. Help trainees set challenging mastery or learning goals.

Answered: 1 week ago

Question

2. Enrolling employees in courses and programs.

Answered: 1 week ago