1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
yuradex [85]
3 years ago
14

Write a Lottery class that simulates a lottery. The class should have an array of five integers named lotteryNumbers. The constr

uctor 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).
Engineering
1 answer:
Bezzdna [24]3 years ago
5 0

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:

You might be interested in
An inductor of ????=6.95 H with negligible resistance is placed in series with a ℰ=12.5 V battery, a ????=3.00 Ω resistor, and a
elena-14-01-66 [18.8K]

Answer:

a) I=0 b) 4.17V c) 0.354 A d) 14.5s

Explanation:

a) consider circuit in the attachment

i(t)= E/R (1- e^(-t/RL))

i(0)= 12.5/3×(1-e^(0/RL))

i(0)=0

b) at t⇒∞

i(∞)= 12.5/3× (1- e^(-∞/RL))

    = 4.17V

c) 1/RL= 1/(6.95×3)= 0.0479616

i(1.85) = 12.5/3 × (1- e^(-1.85×0.0479616)

         = 0.354A

d) I/2= I (1- e^(-t/RL))

t= - RL ln0.5

t= - 3×6.95 × (-0.693)

t= 14.5 s

8 0
4 years ago
The condensed Q formula may be used for operations in which the friction loss can be determined for:
yan [13]

The condensed Q formula may be used for operations in which the friction loss can be determined for a: 3, 4, or 5 inch hose.

<h3>What is a firehose friction loss?</h3>

A firehose friction loss can be defined as a measure of the effect of the resistance of water against the inner side of a firehose, which typically results in a pressure drop at the terminal end.

Generally, some of the factors that affect the resistance or friction in a firehose include:

  • Length of hose.
  • Age of hose.
  • Water flow (gpm)
  • Water turbulence
  • Gravity

Mathematically, the firehose friction loss can be calculated by using this formula:

FL = C × (Q/100)² × L/100.

Read more on friction loss here: brainly.com/question/17305262

#SPJ1

3 0
2 years ago
Car insurance incentives and discounts are available depending on _____. A. school attendance and driver skill B. vehicle type a
borishaifa [10]

Answer:D. Location, vehicle type, and driving habits

7 0
4 years ago
Read 2 more answers
Match the tool to the simple machine.
WITCHER [35]

Answer:

Pulley I think

Explanation:

8 0
3 years ago
Suppose Q1 (0.0, - 3.0 M, 0.0) = 4.0 nC, Q2 (0.0, 3.0 m, 0.0) = 4.0 nC, and Q3 (4.0 m, 0.0, 0.0) = 1.0 nC.
frozen [14]

Answer:

Explanation:

Force on Q₃ due to charge Q₁

= 9 x 10⁹x 4 x 10⁻⁹ x1 x 10⁻⁹ /  5²

= 1.44 x 10⁻⁹ N

Force due to Q₂ will also be 1.44 x 10⁻⁹ N

component of these forces along x axis

-= 2 x 1.44 x 10⁻⁹ cosθ

= 2.88 x  10⁻⁹  x 4/5

= 2.30x10⁻⁹  N along x axis.

The y-component will calcel out.

b ) In this case , Q₁ will repel and Q₂ will attract.

In this case Q₁ will repel and Q₂ will attract. Component along y - axis will be same as earlier one or 2.30x10⁻⁹  N . Component along x axis will cancel out.

c ) Electric field in case 1 and case 2 will be

= 2.30x10⁻⁹  / 1 x 10⁻⁹

= 2.3 N / C , because field is force per unit charge. The sane field will be in case 2 .

5 0
3 years ago
Other questions:
  • Magnesium sulfate has a number of uses, some of which are related to the ability of the anhydrate form to remove water from air
    15·1 answer
  • 10. What main factors influence the choice of electrical wall<br> boxes?
    6·1 answer
  • Choose the best data type for each of the following so that any reasonable value is accommodated but no memory storage is wasted
    5·1 answer
  • Ayo, how do I change my username on here?
    6·1 answer
  • Why/how is a paperclip able to float on water?
    9·1 answer
  • Rod of steel, 200 mm length reduces its diameter (50 mm) by turning by 2 mm with feed speed 25 mm/min. You are required to calcu
    8·1 answer
  • At what distance from the Earth’s surface is a 10,000 kg satellite if its potential energy is equal to –5.58 x 1011 J? (choose t
    5·1 answer
  • Concepts of Engineering and Technology Virt(1) / Unit 3: From Sketches to Products
    14·1 answer
  • What factors affect the temperature when vapor condenses
    12·1 answer
  • Liquid methanol is pumped from a large storage tank through a 1-in.ID pipe at a rate of 3.00gal/mm.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!