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
The only way to print a photo is on a special glossy paper using professional printing services in a store
DaniilM [7]

i believe this is true


8 0
2 years ago
Read 2 more answers
The United States Army retains a history of all equipment acquisition from approval of requirements through funding, authorizing
Mama L [17]

Answer:

A. data mart

Explanation:

Data mart refers to a structure for storing and retrieving data. Often times, the data mart is usually specific to a business line.

The data contained herein is also specific to a particular department and by so doing this facilitate easy isolation, use and development of the data.

The major advantage of creating data marts is for easy accessibility of data.

7 0
3 years ago
What are the benefits of maintaining your vehicle?
Katarina [22]
<span>The correct answer is D - all of the above. It's important to maintain a vehicle to keep it road-worthy for as long as possible without compromising fuel economy, environmental impact or safety. It may also be a legal requirement.</span>
3 0
3 years ago
Read 2 more answers
Which statement describes how to insert the IF, COUNTIF, or SUM function into a cell?
Gre4nikov [31]

Answer:

B Type an = sign in the cell, followed by the name of the function and the relevant arguments.

Explanation:

always look for =

8 0
3 years ago
To solve the difficulty of scaling memory organization, memories are physically organized into a ____-dimensional organization.
Brums [2.3K]

Answer: two

Explanation:

Organizational memory is simply referred to as the accumulation of data or information that have been created for a particular organization.

To solve the difficulty of scaling memory organization, memories are physically organized into a two dimensional organization.

3 0
3 years ago
Other questions:
  • When a relationship is established between two or more arrays by using the same subscript to relate entries between the arrays,
    14·2 answers
  • How does technology helps save the environment?​
    6·1 answer
  • You should structure the<br> first before you search for a relevant picture.
    11·1 answer
  • What does the launcher button do? (From Microsoft Word 2016)
    6·1 answer
  • The scheme function (mult2-diff Ist) should take one argument, a list of numbers, and results in multiplying each number in the
    11·1 answer
  • In a graphical user interface, which is a small symbol on the screen whose location and shape changes as a user moves a pointing
    10·1 answer
  • You are writing a program using the Java language. Which of the following is a requirement of Java syntax?
    6·1 answer
  • What does advance mean​
    6·1 answer
  • If a machine cycle is 2 nanoseconds , how many machine cycles occur each second?
    7·1 answer
  • Pa answer po thank you​
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!