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
A client is looking to maximize value from its Cloud investments by baselining, profiling, and prioritizing its human capital ne
barxatty [35]

myNav is to be present inn the Accenture software. It aim is to helps companies manage the human, technology and business dimensions of cloud change. The myNav module that will help this client is Cloud Advisor.

Cloud Advisor is simply known to be one of the many modules within the myNav platform. It was set up to handle the difficulties of cloud for digital transformation.

These Advisors are  known worldwide community of technical resources. They have a thorough  knowledge of cloud technologies and practices.

Their mission is to know the trends, regulatory implications, and our clients' needs so as to help them to set goals and create plans to achieve their desired outcome.

Learn more from

brainly.com/question/24918185

3 0
3 years ago
What are potential problems with using nanorobots ?
mash [69]
It can penetrate the blood-brain barrier.
5 0
3 years ago
Freeeeeeee brainliest!!!
kondaur [170]

Answer:

Oh Thanks :)

Explanation:

7 0
3 years ago
Which Operating System is used most often in households?
pshichka [43]

Answer:

Windows

Explanation:

Windows are one of the most popular household os.

3 0
2 years ago
Read 2 more answers
Which is an aspect of structural-level design?
DENIUS [597]
I think it’s D. Sorry if it’s wrong
5 0
3 years ago
Read 2 more answers
Other questions:
  • Who was the 1st person to use the term television
    11·1 answer
  • In cell F15, insert a function that will automatically display the word Discontinue if the value in cell D15 is less than 1500,
    6·1 answer
  • Which of the following is not given to a client computer when it is first installed on a TCP/IP network so that it has the appro
    9·1 answer
  • You change a document that is saved on your computer by cutting text from the document what happens to the text when you preform
    5·1 answer
  • When referring to hard drives, access time is measured in
    11·1 answer
  • Individual internet users connect to isps through a(n ________.
    11·1 answer
  • Virus warning don’t go on bit l y links it’s a virus
    12·2 answers
  • Hey guys, I don’t have a problem for you but If anyone knows do you still pass your grade level if you failed 1 class in the las
    11·2 answers
  • What is computer system ?​
    9·2 answers
  • When an EC2 instance is being modified to have more RAM, is this considered Scaling Up or Scaling Out?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!