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
Hunter-Best [27]
3 years ago
5

Write four overloaded methods called randomize. Each method will return a random number based on the parameters that it receives

:
a. randomize() - Returns a random int between min and max inclusive. Must have two int parameters.

b. randomize() - Returns a random int between 0 and max inclusive. Must have one int parameter.

c. randomize() - Returns a random double between min and max inclusive. Must have two double parameters.

d. randomize() - Returns a random double between 0 and max inclusive. Must have one double parameter.
Computers and Technology
2 answers:
Scilla [17]3 years ago
8 0

Answer:

The Java code given below

Explanation:

//import package

import java.util.Scanner;

//Java class

class Lesson_35_Activity {

  // returns random int b/t min and max inclusive; has 2 int parameters

  public static int randomize(int min, int max) {

      int x = (int) (Math.random() * ((max - min) + 1)) + min;

      return x;

 

Yuri [45]3 years ago
6 0

Answer:

The Java code given below

Explanation:

//import package

import java.util.Scanner;

//Java class

class Lesson_35_Activity {

  // returns random int b/t min and max inclusive; has 2 int parameters

  public static int randomize(int min, int max) {

      int x = (int) (Math.random() * ((max - min) + 1)) + min;

      return x;

  }

  // returns random int b/t 0 and max inclusive; has one int parameter

  public static int randomize(int max) {

      int x = (int) (Math.random() * (max + 1));

      return x;

  }

  // returns random double b/t min and max inclusive; two double parameters

  public static double randomize(double min, double max) {

      double x = (double) (Math.random() * ((max - min) + 1)) + min;

      return x;

  }

  // returns random double b/t 0 and max inclusive; has one double parameter.

  public static double randomize(double max) {

      double x = (double) (Math.random() * (max + 1));

      return x;

  }

  // main method, which is entry point of the program

  public static void main(String[] args) {

      // object of Scanner class

      Scanner scan = new Scanner(System.in);

      // asking min and max number

      System.out.print("Enter min number : ");

      int mi = scan.nextInt();// reading min number

      System.out.print("Enter max number : ");

      int ma = scan.nextInt();// reading max number

      // checking number

      if (mi < ma) {

          System.out.println(randomize(mi, ma));// method call

          System.out.println(randomize(0, ma));// method call

          double mii = mi;

          double maa = ma;

          System.out.printf("%.2f", randomize(mii, maa));

          System.out.printf("\n%.2f", randomize(0, maa));

      } else {

          // when minimum number is greater than maximum number then display

          System.out.println("Enter min number " + mi + " should be less than max " + ma);

      }

  }

}

You might be interested in
If Number = 7, what will be displayed after code corresponding to the following pseudocode is run? (In the answer options, new l
kherson [118]

Answer:

5,10; 6,12; 7,14

Explanation:

We will demonstrate the iteration of the loop:

First iteration: Number = 7, Count = 5 at the beginning. We will check if Count <= Number? Since it is correct, prints 5,10. Increment the Count by 1.

Second iteration: Number = 7, Count = 6. We will check if Count <= Number? Since it is correct, prints 6,12. Increment the Count by 1.

Third iteration: Number = 7, Count = 7. We will check if Count <= Number? Since it is correct, prints 7,14. Increment the Count by 1.

Forth iteration: Number = 7, Count = 8. We will check if Count <= Number? Since it is not correct, the loop stops.

8 0
3 years ago
The fast movement of briefly flashed images in an animated motion picture produces what effect? subliminal messaging convergence
REY [17]

Answer:

The answer is Stroboscopic movement

Explanation:

Stroboscopic movement occurs when we do not see a motion continuously but in discrete shots. It is an effect in which we see an object at one place and after another instant the object seems to have shifted it's position.

Auto kinetic effect is an effect in which a stationary point of light appears to move.It occurs as our brains can perceive motion relative to some other object and cannot observe ,motion along a featureless terrain or environment.

Phi effect causes an observer to perceive motion in stationary objects.

3 0
3 years ago
1. Give state diagrams of DFAs recognizing the following languages. The alphabet is {0, 1}. (a) {w | w is any string except 11 a
storchak [24]

Answer:

Explanation:

The first diagram shows the DFA that accepts that accepts any string except 11 and 111

The second diagram shows every odd position of w is 1

6 0
3 years ago
What are the differences between switches and routers? cse question
deff fn [24]

Answer:

The main objective of router is to connect various networks simultaneously and it works in network layer

Explanation:

The main objective of router is to connect various networks simultaneously and it works in network layer

7 0
3 years ago
Write a BASIC program to find the product of any two numbers​
GuDViN [60]

Answer:

Print 4 + 4

Explanation:

If you're writing this in the programming language called BASIC, this is how you would add any two numbers.

6 0
3 years ago
Other questions:
  • Businesses have taken advantage of many of the smart phone features to promote their business. TRUE OR FALSE
    5·2 answers
  • How is typing speed measured
    12·2 answers
  • How can a wiki contribute to an academic paper?
    9·2 answers
  • 3. What term refers to the physical locations of elements in relation to each other?
    10·2 answers
  • A network administrator recently implemented two caching proxy servers on the network. how can the administrator best aggregate
    5·1 answer
  • Write a function that will alphabetize a string WITHOUT using the sort function :
    7·1 answer
  • The IT department sent out a memo stating that it will start delivering desktop computer interfaces through the IT data center v
    5·1 answer
  • Charles Mott works for a company called VeriSign that acts a trusted third party to verify information. One of Charles' largest
    15·1 answer
  • package dataStructures; /** * Class OrderedLinkedList. * * This class functions as a linked list, but ensures items are stored i
    8·1 answer
  • Read two numbers from user input. Then, print the sum of those numbers. Hint - Copy/paste the following code, then just type cod
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!