Write a Lottery class that simulates a lottery. The class should have an array of five integers named lotteryNumbers. The constructor should use the Random class (from the Java API) to generate a random number in the range of 0 through 9 for each element in the array. The class should also have a method that accepts an array of five integers that represent a person’s lottery picks. The method is to compare the corresponding elements in the two arrays and return the number of digits that match. For example, the following shows the lotteryNumbers array and the user’s array with sample numbers stored in each. There are two matching digits (elements 2 and 4).

Answers

Answer 1
Answer:

Answer:

Output:-

Enter the five digit lottery number

Enter the digit 1 : 23

Enter the digit 2 : 44

Enter the digit 3 : 43

Enter the digit 4 : 66

Enter the digit 5 : 33

YOU LOSS!!

Computer Generated Lottery Number :

|12|38|47|48|49|

Lottery Number Of user:

|23|33|43|44|66|

Number Of digit matched: 0

Code:-

import java.util.Arrays;

import java.util.Random;

import java.util.Scanner;

public class Lottery {

int[] lotteryNumbers = new int[5];

public int[] getLotteryNumbers() {

return lotteryNumbers;

}

Lottery() {

Random randomVal = new Random();

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

lotteryNumbers[i] = randomVal.nextInt((50 - 1) + 1);

}

}

int compare(int[] personLottery) {

int count = 0;

Arrays.sort(lotteryNumbers);

Arrays.sort(personLottery);

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

if (lotteryNumbers[i] == personLottery[i]) {

count++;

}

}

return count;

}

public static void main(String[] args) {

int[] personLotteryNum = new int[5];

int matchNum;

Lottery lnum = new Lottery();

Scanner input = new Scanner(System.in);

System.out.println("Enten the five digit lottery number");

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

System.out.println("Enter the digit " + (i + 1) + " :");

personLotteryNum[i] = input.nextInt();

}

matchNum = lnum.compare(personLotteryNum);

if (matchNum == 5)

System.out.println("YOU WIN!!");

else

System.out.println("YOU LOSS!!");

System.out.println("Computer Generated Lottery Number :");

System.out.print("|");

for (int i = 0; i < lnum.getLotteryNumbers().length; i++) {

System.out.print(lnum.getLotteryNumbers()[i] + "|");

}

System.out.println("\n\nLottery Number Of user:");

System.out.print("|");

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

System.out.print(personLotteryNum[i] + "|");

}

System.out.println();

System.out.println("Number Of digit matched: " + matchNum);

}

}

Explanation:


Related Questions

A student takes 60 voltages readings across a resistor and finds a mean voltage of 2.501V with a sample standard deviation of 0.113V. Assuming that errors are due to random processes, how many of the readings are expected to be greater than 2.70V?
The Rappahannock River near Warrenton, VA, has a flow rate of 3.00 m3/s. Tin Pot Run (a pristine stream) discharges into the Rappahannock at a flow rate of 0.05 m3/s. To study mixing of the stream and river, a conserva- tive tracer is to be added to Tin Pot Run. If the instruments that can mea- sure the tracer can detect a concentration of 1.0 mg/L, what minimum concentration must be achieved in Tin Pot Run so that 1.0 mg/L of tracer can be measured after the river and stream mix? Assume that the 1.0 mg/L of tracer is to be measured after complete mixing of the stream and Rappa- hannock has been achieved and that no tracer is in Tin Pot Run or the Rap- pahannock above the point where the two streams mix. What mass rate (kg/d) of tracer must be added to Tin Pot Run?
The process in which the system pressure remain constant is called a)-isobaric b)-isochoric c)-isolated d)-isothermal
An experimental arrangement for measuring the thermal conductivity of solid materials involves the use of two long rods that are equivalent in every respect, except that one is fabricated from a standard material of known thermal conductivity kA while the other is fabricated from the material whose thermal conductivity kB is desired. Both rods are attached at one end to a heat source of fixed temperature Tb, are exposed to a fluid of temperature [infinity] T[infinity], and are instrumented with thermocouples to measure the temperature at a fixed distance x1 from the heat source. If the standard material is aluminum, with kA= 200 W/m·K, and measurements reveal values of TA= 75°C and TB= 70°C at x1 for Tb= 100°C and [infinity] T[infinity]= 25°C, what is the thermal conductivity kB of the test material?
(d) Arches NP is known for its spectacular arches that develop in the jointed areas of the park. Placemark Problem 2d flies you to Landscape Arch, the arch with the largest span in Arches NP. If the stresses that stretched the rock to form the joints were oriented perpendicular to the joint surfaces and the rock fins that contain the arches, what was the direction that the rocks were stretched? ☐ N-S ☐ E-W☐ NW-SE ☐ NE-SW

What is a SAFETY CHECK

Answers

Answer:

Safety check is defined as rounding to make sure that the patients and the milieu (patients living quarters) is secured and free of harmful items that can be used to hurt someone.

If you are pouring a large concrete slab and wish to avoid random cracks caused by shrinkage, you would likely provideA. expansion joints
B. isolation joints
C. control joints
D. construction joints

Answers

If you are pouring a large concrete slab and wish to avoid random cracks caused by shrinkage, you would likely provide Control joints. The correct answer would be C.

Control joints are used to prevent random cracks from forming in large concrete slabs caused by shrinkage. These joints are placed at strategic locations in the slab to allow for the concrete to expand and contract without cracking. Expansion joints, on the other hand, are used to separate concrete from other structures or materials, and isolation joints are used to separate different sections of concrete.

Construction joints are used to connect two different pours of concrete. Therefore, the best option for preventing random cracks caused by shrinkage would be to use control joints.

Learn more about Control joints:

brainly.com/question/1992029

#SPJ11

Assuming that the following three variables have already been declared, which variable will store a Boolean value after these statements are executed? choice = true;
again = "false";
result = 0;

a. choice
b. again
c. result
d. none of these are Boolean variables

Answers

Answer:

C

Explanation:

Boolean Algebra deals with either a one or a zero and how to manipulate them in computers or elsewhere. The "choice" option may not work, since for text it must be enclosed in quotation marks, usually. For "again," it's text and not a 1 or 0. So, the answer is C, since this is a 0.

Cody’s car accelerates from 0m/s to 45 m/s northward in 15 seconds. What is the acceleration of the car

Answers

Answer:

3 m/s²

Explanation:

Acceleration is calculated as :

a= Δv/ t

where ;

Δv = change in velocity

Δv = 45 - 0 = 45  m/s

t= 15 s

a= 45 /15

a= 3 m/s²

. Were you able to observe ???? = 0 in the circuit you constructed during lab? Why or why not? Hint: What value of resistance would be needed for ???? = 0? 2. What feature in the time response of an RLC circuit distinguishes a critically damped response from an underdamped response? 3. Why must an op-amp be powered to be used in a circuit? 4. If you were handed a parts kit with an unknown op-amp, what information would you need to find prior to using it in a circuit?

Answers

Answer:

an attachment is below

Explanation:

1) the formula for damping coefficient id for RLC series circuit.

For \xi =0 you can make c=0 but inductor will still have some capacitance.

2) the responses of critically damped system and under damped system are shown with comments on their time response.

4) There can be many different answers to this question, but the 4 I have mentioned are the most important parameters we need to know about an unknown op-amp if we are to use it in our circuit.

Hope it answers all your questions.

Describe the difference between design guidelines or criteria and design performance. Explain the relationship between the use of guideline/criteria tools and performance tools during the design process

Answers

Answer:

PART A

Design guidelines are sets of procedures to be followed in order to enhance the designing of an object or other things.

Design Performance is the actual process of carrying out the design process of an object using the design guidelines or criteria.

PART B

(1) Design guidelines tools helps to enhance design Performance.

(2) Design guidelines tools helps the designing performance tools to be effective.

Explanation:Design guidelines are the various steps which has special tools used to guide the designer in order to enhance the designing performance tools and ensure that the design process is done devoid of errors.

Design Performance tools are tools which helps to enhance the actual design Activities.