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
I should over-tighten bolts so that my creations do not fall apart.​
Katarina [22]
Is this even a question ?
5 0
3 years ago
How to pass sharp edged tools to another student in welding
lisov135 [29]

Answer: When walking with a sharp tool, the tool should be carried with the blade down and away from the body. When climbing with a sharp tool, tool belts, or buckets with hand lines should be used so workers can have both hands to grip the ladder.

Explanation:

3 0
3 years ago
Appliances that use force voltage analogy
Inga [223]
Answer: resistor

Explanation: Not quite sure. Need more research
5 0
3 years ago
A unidirectional E-Glass fiber-epoxy composite material contains 61% by volume E-Glass fibers stressed under isostrain condition
zalisa [80]

Answer:

The total load carried by the fiber will be "98%".

Explanation:

The given values are:

V_{f}=0.61

V_{m}=1-V_{f}

     =1-0.61

     =0.39

E_{f}=10 \ Mpa

\sigma_{f}=0.35 \ Mpa

E_{m}=0.45 \ Mpa , \sigma_{m}=9\times 10^{-3} \ Mpa

As we know,

⇒  E_{e}=fE_{f}+mE_{m}

On putting the estimated values, we get

⇒       =0.61\times 10+0.39\times 0.95

⇒       =6.27 \ Mpa

Now,

⇒  \sigma_{c}=f\sigma_{f}+m\sigma_{m}

On putting the estimated values, we get

⇒       =0.61\times 0.35+0.39\times 0.009

⇒       =0.217 \ Mpa

Therefore,

The load carried by fiber,

=\frac{f\sigma_{f}}{\sigma_{c}}

=\frac{0.35\times 0.61}{0.217}

=0.98 i.e., 98%

4 0
4 years ago
The elementary liquid-phase series reaction
liraira [26]

Answer:

Concentration of A: \frac{C_{A} }{C_{Ao} } =e^{-k_{1}t }

Concentration of B: \frac{C_{B} }{C_{Ao} } =\frac{k_{1} }{k_{2}-k_{1}  } (e^{-k_{1}t } -e^{-k_{2}t } )

Concentration of C: \frac{C_{C} }{C_{Ao} } =1+\frac{k_{1} }{k_{2}-k_{1}  } e^{-k_{2}t } -\frac{k_{2} }{k_{2}-k_{1}  } e^{-k_{1} t}

the image shows the graphs of the three concentrations

Explanation:

We have the reaction:

A ------->k1--------->B------------->k2--------->C

Each reaction:

r_{A} =-k_{1} C_{A} \\r_{B} =k_{1} C_{A} -k_{2} C_{B} \\r_{C} =k_{2} C_{C}

Where Cn is the concentration of each specie (A,B,C)

The mass balance for A:

-\frac{dC_{A} }{dt} =-r_{A} \\-\frac{dC_{A} }{dt}=k_{1} C_{A} \\-\int\limits^y_x {\frac{dC_{A} }{dt} } \,=k_{1} t\\\frac{C_{A} }{C_{Ao} } =e^{-k_{1}t }

Where x=CAo and y=CA

The mass balance for B:

-\frac{dC_{B} }{dt} =-r_{B} \\-\frac{dC_{B} }{dt}=k_{2} C_{B} -k_{1} C_{A} \\\frac{dC_{B} }{dt}+k_{2} C_{B}=k_{1} C_{A}\\\frac{C_{B} }{C_{Ao} } =\frac{k_{1} }{k_{2}-k_{1}  } (e^{-k_{1}t }-ex^{-k_{2}t }  )

The mass balance for C:

\frac{C_{C} }{C_{Ao} } =1-\frac{C_{A} }{C_{Ao} } -\frac{C_{B} }{C_{Ao} } \\\frac{C_{C} }{C_{Ao} }=1+\frac{k_{1} }{k_{2}-k_{1}  } e^{-k_{2} t}-\frac{k_{2} }{k_{2}-k_{1}  }  e^{-k_{1}t }

The maximum concentration of C is:

C_{Cmax} =C_{Ao} (\frac{k_{2} }{k_{1} } )^{\frac{k_{2} }{k_{2}-k_{1}  }}  =1.6(\frac{0.01}{0.4} )^{\frac{0.01}{0.01-0.4} } =1.76mol/dm^{3}

and the maximum time is:

t_{max} =\frac{ln\frac{k_{2} }{k_{1} } }{k_{2}-k_{1}  } =\frac{ln\frac{0.01}{0.4} }{0.01-0.4} =9.4 h

6 0
3 years ago
Other questions:
  • Which of the following is important in career planing
    5·1 answer
  • A ceramic material can be defined as an organic compound consisting of a metal or semimetal and one or more nonmetals: (a) true
    9·1 answer
  • Ame:<br> 7. A step-down transformer reduces the primary current.<br> True or false
    8·2 answers
  • 2. What formula relates work and power?​
    10·1 answer
  • What limits the practical realization of higher efficiencies in the Otto cycle?
    7·1 answer
  • The electric motor exerts a torque of 800 N·m on the steel shaft ABCD when it is rotating at a constant speed. Design specificat
    13·2 answers
  • A local surf report provides the height of the wave from the trough to the crest of the wave. How does this relate to the wave’s
    11·1 answer
  • What are examples of Quality Assurance workplaces? Check all that apply.
    12·2 answers
  • I just need help on problem B
    9·1 answer
  • Who is the first engineer of world ? and why?​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!