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
What happens? In word 2016 when the home ribbon tab is clicked on ?
RideAnS [48]

When you clicked on the ribbon tab in word 2016, you'd be brought to the home tab, where all of the basic controls are displaced for you to see.

Hope I could help! :)

5 0
3 years ago
Read 2 more answers
B. Find Addition of Binary Numbers: 1100112 + 11012
schepotkina [342]
Hello, I assume you mean 110011_2 + 1101_2

To add 110011+ 1101 we can setup the problem like the following:

   110011
+     1101 
-------------
  1000000

When we add 1 + 1 this equals 10 so we just carry the 1 and we keep doing that from right to left. Also 1 + 0 = 1 

7 0
2 years ago
Understanding that protection of sensitive unclassified information is:
AfilCa [17]

Answer:

Not necessarily malignant

Explanation:

As the word "unclassified" shows it's not damaging, however I still doesn't recommend if it's not necessary.

4 0
2 years ago
Characteristics of 1st generation​ computers
jasenka [17]

Answer:

use of vacume tubes to make circuit

use of punch cards as I/O devices

use of high electricity

use of magnetic drums

use of machine language and symbols in instuctons

4 0
2 years ago
Modify the FitnessTracker class, created in Chapter 4 Programming Exercise 3AB, so that the default constructor calls the three-
Ivenika [448]

Answer:

Is this coding?

Explanation:

5 0
2 years ago
Other questions:
  • The use of computers to combine data from multiple sources and create electronic dossiers of detailed information on individuals
    8·1 answer
  • Which of the following protocols support the encryption and decryption of e-mail messages?
    13·1 answer
  • Consider the following code: public static void mystery(int a) { System.out.println("A"); } public static void mystery(double a)
    6·1 answer
  • Which of the following is NOT a useful strategy when making an informed purchase ?
    7·1 answer
  • Use the drop-down menus to complete the statements about using column breaks in word 2016
    6·2 answers
  • You are writing a program using the Java language. Which of the following is a requirement of Java syntax?
    6·1 answer
  • A developer wants to take existing code written by another person and add some features specific to their needs. Which of the fo
    9·1 answer
  • The height of a small rocket y can be calculated as a function of time after blastoff with the following piecewise function: y 5
    10·1 answer
  • The computer stores currently used programs and data in ________.
    9·2 answers
  • if we intend to include a servo motor as an actuator, what feature should we include when selecting a microcontroller?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!