Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

HELP! NEEDED IN BASIC BEGINNER JAVA WITH NO CASES! Write a program that simulates a basic lottery. Your user will purchase one lottery ticket. Each

HELP! NEEDED IN BASIC BEGINNER JAVA WITH NO CASES!

Write a program that simulates a basic lottery.

Your user will purchase one lottery ticket. Each ticket will contain 5 numbers. Each number will be between 1 and 20, inclusive. You will allow the user to select their own numbers for their ticket or to have the computer randomly select the numbers. You should represent the ticket using an array.

Once the ticket has been purchased, your program will randomly generate the winning lottery numbers and determine if the user has won. The winning lottery numbers should be stored in a separate array.

Heres the fun part your program should continue to generate a full set of winning lottery numbers drawings until your user wins the lottery. Your program will count the number of lottery drawings it takes to win.

A few things to consider:

The program should contain the following methods

o A main method o A method that determines the users ticket numbers o A method that determines the winning lottery numbers o A method that determines if the user has a winning ticket o A method that displays the following to the screen:

A message indicating the win

The numbers in the users ticket when the win occurred

The winning lottery ticket numbers

The number of times it took to get a match with a winning ticket

The number of times each value 1-20 was generated for a winning lottery ticket

The number(s) generated most often for the winning lottery tickets during this run of the

program

For the sake of simplicity, you should implement your code to prevent duplicate values in the lottery

tickets (ie a specific number should only appear one time in any ticket). You will need to write code to ensure the user doesnt select the same number twice and that the computer doesnt generate the same number twice.

The numbers do not have to match in order. For example, a user ticket with numbers 1, 2, 3, 4, 5 should be considered a match if the winning ticket numbers are 5, 2, 1, 3, 4.

You must validate all user input.

Numeric output should be displayed with commas

The code should be written using efficient processing.

Remember to use good programming practices (comments, naming conventions, program structure,

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_2

Step: 3

blur-text-image_3

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

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

Students also viewed these Databases questions

Question

Derive expressions for the rates of forward and reverse reactions?

Answered: 1 week ago

Question

Write an expression for half-life and explain it with a diagram.

Answered: 1 week ago

Question

What do you mean by underwriting of shares ?

Answered: 1 week ago

Question

Define "Rights Issue".

Answered: 1 week ago