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
pshichka [43]
2 years ago
14

Exercise : Randomizer In this exercise, we are going to create a static class Randomizer that will allow users to get random int

eger values from the method nextInt() and nextInt(int min, int max). Remember that we can get random integers using the formula int randInteger = (int)(Math.random() * (range + 1) + startingNum). nextInt() should return a random value from 1 - 10, and nextInt(int min, int max) should return a random value from min to max. For instance, if min is 3 and max is 12, then the range of numbers should be from 3 - 12, including 3 and 12.
Computers and Technology
1 answer:
Nutka1998 [239]2 years ago
4 0

Answer:

Here the code is by using java.

Explanation:

//Randomizer.java

public class Randomizer {

public static int nextInt() {

//get random number from 1-10

int randInteger = (int) (Math.random() * (11) + 1);

//if number is greater than 10 or less than 1

while (randInteger > 10 || randInteger < 1) {

randInteger = (int) (Math.random() * (11) + 1);

}

return randInteger;

}

public static int nextInt(int min, int max) {

//formula to get random number from min-max

int randInteger = (int) (Math.random() * (max + 1) + min);

while (randInteger > max || randInteger < min) {

randInteger = (int) (Math.random() * (max + 1) + min);

}

return randInteger;

}

}

//RandomizerTester.java

public class RandomizerTester {

public static void main(String[] args) {

System.out.println("Results of Randommizer.nextInt()");

for (int i = 0; i < 10; i++) {

System.out.println(Randomizer.nextInt());

}

int min = 5;

int max = 10;

System.out.println("\n Results of Randomizer.nextInt(5,10)");

for (int i = 0; i < 10; i++) {

System.out.println(Randomizer.nextInt(min, max));

}

}

}

OUTPUT:

Results of Randommizer.nextInt()

9

2

3

8

5

9

4

1

9

2

Results of Randomizer.nextInt(5,10)

9

8

9

7

5

10

5

10

7

7

You might be interested in
Based on your research and understanding, write a 3- to 4-page Microsoft Word document that:
Over [174]

Answer:

....

Explanation:

3 0
3 years ago
Question 11
STatiana [176]

What type of program would have a class named Student with objects called fullTime and partTime?

A. machine language program

B. object-oriented program

C. markup language program

D. procedural language program

Answer:

B. object-oriented program

Explanation:

An object-oriented program or OOP is a type of program that uses the concepts of objects and methods.

Although they are quite broad, they also make use of classes and types.

Java, for instance makes use of OOP as they use classes and objects under those classes and name them anyhow they want.

Therefore, the correct answer is B

8 0
3 years ago
1:A presentation program which is developed by Microsoft
LekaFEV [45]
Option 3: PowerPoint.
4 0
2 years ago
Read 2 more answers
Which tool can be used to code basic HTML?<br><br> Text editor<br> JavaScript<br> CSS<br> HTML
luda_lava [24]

Answer:

Java Script

Explanation:

3 0
2 years ago
Read 2 more answers
Which of the following CANNOT be done in Normal view A. Enter bolded text in the Notes Pane B. Delete previously entered notes i
blondinia [14]

Answer:

<em>Well, Your answer will be is </em><em>B. Delete previously entered notes in the Notes Pane. Good Luck!</em>

3 0
3 years ago
Other questions:
  • Jenny wants to create a résumé after a two-years gap. What should she consider?
    11·2 answers
  • The operating system provides a ____, which is the means with which you interact with the computer
    5·1 answer
  • How do you think computers have helped improve documentation, support and services within the healthcare industry
    13·1 answer
  • While reviewing the Quick Access toolbar, Sarah notices that the Redo button is not there. This is because the Redo button only
    12·1 answer
  • What are examples of templates the Input Mask Wizard offers? Check all that apply.
    12·2 answers
  • Describe two different examples of potential conflicts, and explain why these conflicts can have a negative impact on
    14·1 answer
  • Decimal numbers is equivalent to binary 110
    5·1 answer
  • TIMED QUIZ
    12·1 answer
  • Which are the top 10 Popular Cars and Video Games get max ammount of point that we can give​
    12·2 answers
  • _______________________ variables do not need to be declared inside the function definition body, they get declared when the fun
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!