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]
3 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]3 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
Why we can not see objects around us in the dark​
malfutka [58]

Answer:

We see an object when light falls on it and gets reflected from its surface and enters our eyes. In a dark room, there is no source of light. no light falls on the surface of objects and we do not see them. This is why we cannot see the objects in a dark room.

4 0
4 years ago
In order to avoid slipping in the shop, your footwear should ___________.
Arisa [49]

Answer:

b

Explanation:

has traction so it can grip

4 0
3 years ago
Marissa bought 2 and 1/2 gallons of orange juice to make punch how many quarts of orange juice did Marissa Buy
Vladimir [108]
1 gallon = 4 quarts
using this information, you can then use simple proportion.
if 1 gallon = 4 quarts 
then to find the amount of quarts in 2 and 1/2 gallons, you multiply 2 and 1/2 by 4 which should give you 10 gallons
5 0
3 years ago
Read 2 more answers
How do i find the greatest common factor of two numbers?
Lilit [14]
You can list the numbers . keep listing them till you find the same numbers
8 0
3 years ago
Stella has captured this candid photograph of a man who was reunited with his son. She has used facial retouching in each of the
riadik2000 [5.3K]

Answer: The last picture it looks better.

Explanation: Welcome!

8 0
3 years ago
Read 2 more answers
Other questions:
  • The animation industry is solely reliant on 3-D modeling and 3-D virtualization to create the animated movies in the cinemas.
    9·2 answers
  • What kind of firewall can block designated types of traffic based on application data contained within packets?
    7·1 answer
  • What is basic statement made up of​
    10·2 answers
  • One of the best examples of outcome control is the re-hiring of Steve Jobs by Apple as CEO
    14·1 answer
  • Design a program that will receive a valid time in the 24-hour format (e.g. 2305) and convert to its equivalent 12-hour format (
    14·1 answer
  • Advantage of realtime processing​
    14·1 answer
  • What is essence of computer systems and networks?​
    9·1 answer
  • Three Cat 5e cables were run from an office area to three computers in a machine shop. Work took place on the weekend when the m
    14·1 answer
  • Vocational counselors group career and occupation specialties into <br> career clusters.
    12·1 answer
  • The software that requests mail delivery from the mail server to an Internet device is known as mail ____ software.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!