Computers and Technology

In this exercise, we are going to create a static class Randomizer that will allow users to get random integer 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.

This is what I have so far:

public class RandomizerTester
{
public static void main(String[] args)
{

System. out. println("Results of Randomizer. nextInt()");
for(int i = 0; i < 10; i++)
{
System. out. println(Randomizer. nextInt());
}

//Initialize min and max for Randomizer. nextInt(min, max)
int min = 5;
int max = 10;
System. out. println("\nResults of Randomizer. nextInt(5,10)");
for(int i = 0; i < 10; i++)
{
System. out. println(Randomizer. nextInt(min ,max));
}

}
}

public class Randomizer
{
private static int range;
private static int startingNum;
private static int nextInt;
private static int max;
private static int min;

public static int nextInt()
{
//Implement this method to return a random number from 1-10
//Randomizer randInteger = new Randomizer();
int randInteger = (int)(Math. random() * (11) + startingNum);
return Randomizer. nextInt;
}

public static int nextInt(int min ,int max)
{
//Implement this method to return a random integer between min and max
int randInteger = (int)(Math. random() * (max - min + 1) + min);
return Randomizer. nextInt(min, max);

}
}

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 14:00, broyochey1
Given the resulting p-values, would you reject or fail to reject the null hypotheses (assuming a 0.05 significance level)? what does your decision mean in the context of this problem? would you proceed with changing the design of the arrow, or would you keep the original design?
Answers: 2
image
Computers and Technology, 22.06.2019 13:30, AsiaDeas4078
Write lines of verse that rhyme to remember the following information: acid rain is a type of air pollution caused by chemicals in the air.
Answers: 1
image
Computers and Technology, 22.06.2019 14:20, capo9972
Cengagenowv2 is a comprehensive online learning tool. using cengagenowv2, you may access all of the following except: 2. each time you log in, cengagenowv2 automatically performs a system check and informs you if your computer does not meet the cengagenowv2 system requirements. 3. which tab/page allows you to easily track your assignment scores, number of submissions, time spent, as well as the ability view assign
Answers: 3
image
Computers and Technology, 22.06.2019 19:00, dadonelson2109
If your accelerator suddenly gets stuck what should you do
Answers: 2
Do you know the correct answer?
In this exercise, we are going to create a static class Randomizer that will allow users to get rand...

Questions in other subjects:

Konu
Mathematics, 23.12.2020 22:10