subject

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);

}
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 14:00
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
question
Computers and Technology, 22.06.2019 18:40
Mariah was working on a multimedia presentation that included both video and audio files. the file was huge, and she wanted to send it to her coworker in another office. she needed to reduce the size of the file so that it could be transmitted faster. the utility she used to do this was
Answers: 2
question
Computers and Technology, 22.06.2019 19:20
Consider the following code snippet: #ifndef cashregister_h#define cashregister_hconst double max_balance = 6000000.0; class cashregister{public: cashregister(); cashregister(double new_balance); void set_balance(double new_balance); double get_balance() const; private: double balance[12]; }; double get_monthly_balance(cashregister bk, int month); #endifwhich of the following is correct? a)the header file is correct as given.b)the definition of max_balance should be removed since header files should not contain constants.c)the definition of cashregister should be removed since header files should not contain class definitions.d)the body of the get_monthly_balance function should be added to the header file.
Answers: 1
question
Computers and Technology, 23.06.2019 07:50
Apython programming question: assume s is a string of lower case characters. write a program that prints the number of times the string 'bob' occurs in s. for example, if s = 'azcbobobegghakl', then your program should print number of times bob occurs is: 2
Answers: 3
You know the right answer?
In this exercise, we are going to create a static class Randomizer that will allow users to get rand...
Questions
question
Mathematics, 31.03.2020 23:05
question
Mathematics, 31.03.2020 23:06
question
Mathematics, 31.03.2020 23:06
question
Mathematics, 31.03.2020 23:06
question
Mathematics, 31.03.2020 23:06
Questions on the website: 13722363