Java programming

Assignment Help Basic Computer Science
Reference no: EM131979228

Java programming

A program that simulates a lottery. The program should have array of 6 integers named winning, with a randomly generated number in the range of 1 through 9 for each element in the array. The program should ask user to enter 6 numbers and store them in another integer array named player. The program then compares the numbers in 2 arrays to find out how many numbers match.

If the two numbers are on the same position in both arrays, it is a match. (This is using parallel array concept to compare two arrays.) The program output should display the winning numbers, player's numbers, and how many numbers matched. For instance, if your winning numbers are 3,5,9,1,4,7 and your player's numbers are 2,5, 7,1, 9,8, then you have two matches (5 and 1). 5 is on the second position and 1 is on the fourth position in both arrays.

Input Validation: Do not accept player's number out of range of 1-9.

Use the following design tips

1. Create two integer arrays with 5 elements each.

2. You can create methods such as generateWinningNumber, getPlayerNumber, getMatches, and printNumber.

3. Use Random class to generate random numbers. Here is the example of how to create method generateWinningNumber;

public static void generateWinningNumber(int[] wList)

{

Random rNum = new Random();

final int MIN=1, MAX=9;

for (int i=0; i<wList.length;i++)

{

wList[i]=rNum.nextInt(MAX-MIN+1)+MIN;

}

}

 

4. Use for loop to complete each task.

 

5. Use while loop to validate user input as follows;

 

while (pList[i]<1 || pList[i]>9) //pList is the array of player number

{

System.out.print("Invalid Number. Enter number 1-9:");

pList[i]=input.nextInt();

}

6. To compare two arrays to find out the matches, use the following code;

 

for (int i=0; i<pList.length; i++) //pList is the array of player numbers

{

if (wList[i]==pList[i]) //wList is the array of winning numbers

match++;

}

If someone could help me solve this and possibly give me some tips on how these should be laid out, I would be very appreciative.

Reference no: EM131979228

Questions Cloud

Internal fragmentation for a process : How much memory is consumed by the first and second level page tables and wasted by internal fragmentation for a process that has 64K of memory starting.
Providing a high-performance memory hierarchy to processors : Caches are important to providing a high-performance memory hierarchy to processors. Below is a list of 32-bit memory address references
What do investors expect stock to sell for at end of year : What do investors expect the stock to sell for at the end of the year?
Relationship between humankind-technology in information age : The Second Renaissance and How do you think films explore the relationship between humankind and technology in the Information Age?
Java programming : A program that simulates a lottery. The program should have array of 6 integers named winning, with a randomly generated number in the range of 1 through
Configuring ad fs to use the sql database : Describe the steps necessary to configuring AD FS to use the SQL database.
Steps necessary to issuing certificates : As an administrator for the Contoso Corporation, describe the steps necessary to issuing certificates to your users that are recognized by external clients.
New virtualized environment consisting : You are the administrator for the Contoso Corporation and you have been using a new virtualized environment consisting of 27 Hyper-V servers
Describe the actions you must take to migrate : Describe the actions you must take to migrate the VMs to the Hyper-V hosts.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd