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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 03:00, Emanuelle7843
Which action describes an aspect of technological design?
Answers: 1
image
Computers and Technology, 22.06.2019 22:50, youngboymark123
Assume the existence of a bankaccount class. define a derived class, savingsaccount that contains two instance variables: the first a double, named interestrate, and the second an integer named interesttype. the value of the interesttype variable can be 1 for simple interest and 2 for compound interest. there is also a constructor that accepts two parameters: a double that is used to initialize the interestrate variable, and a string that you may assume will contain either "simple", or "compound", and which should be used to initialize the interesttype variable appropriately. there should also be a pair of functions getinterestrate and getinteresttype that return the values of the corresponding data members (as double and int respectively).
Answers: 2
image
Computers and Technology, 23.06.2019 16:00, natasniebow
Kenny works with an it company. his company is about to launch new software in the market. he has to ensure that this new software is functional and meets all of the quality standards set up at the planning stage. which job profile is kenny likely to have? kenny is likely to have the job profile of a blank .
Answers: 2
image
Computers and Technology, 23.06.2019 17:30, Annlee23
When making changes to optimize part of a processor, it is often the case that speeding up one type of instruction comes at the cost of slowing down something else. for example, if we put in a complicated fast floating-point unit, that takes space, and something might have to be moved farther away from the middle to accommodate it, adding an extra cycle in delay to reach that unit. the basic amdahl's law equation does not take into account this trade-off. a. if the new fast floating-point unit speeds up floating-point operations by, on average, 2ă—, and floating-point operations take 20% of the original program's execution time, what is the overall speedup (ignoring the penalty to any other instructions)? b. now assume that speeding up the floating-point unit slowed down data cache accesses, resulting in a 1.5ă— slowdown (or 2/3 speedup). data cache accesses consume 10% of the execution time. what is the overall speedup now? c. after implementing the new floating-point operations, what percentage of execution time is spent on floating-point operations? what percentage is spent on data cache accesses?
Answers: 2
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 in other subjects:

Konu
Mathematics, 21.08.2020 07:01