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
What type of software is an antivirus?
Kamila [148]

Answer: what type of software is an antivirus?

Answer: A security software

Explanation:

Antivirus software is a type of security software designed to protect users from multiple types of malware, not just viruses. The software is a risk management tool that scans devices regularly and on-demand for known malware and suspicious behavior associated with malware.

6 0
2 years ago
Read 2 more answers
A company wants to build a new type of spaceship for transporting astronauts to the moon. What should the company do first?
Paraphin [41]

Answer:

Think of some ideas of how their gonna create the new spaceship

Explanation:

Because I'm Smort (typo intended)

4 0
3 years ago
Read 2 more answers
write a function that takes two integer arrays as input return true if any two of the numbers in the first array input add up to
Afina-wow [57]

Answer:

Explanation:

This program is written in Python. It is a function that takes in two arrays. Then it loops through the first array twice, adding each element with the others and comparing the sum to the values in the second array. If a similar value is found in the second array, the program prints out the value and returns True to the user. Otherwise, it returns False. A test case has been created with two array variables that print out False, the output can be seen in the attached image below.

def sumArray(arr1, arr2):

   for i in range(len(arr1)):

       for x in range(len(arr1)):

           sum = 0

           if i != x:

               sum = arr1[i] + arr1[x]

           if sum in arr2:

               print(str(sum) + "Found in Second Array")

               return True

   return False

arr1 = [1, 9, 10, 44]

arr2 = [2, 4, 8, 14]

print(sumArray(arr1, arr2))

8 0
3 years ago
you need to configure a wireless network using wpa2-enterprise. which of the following components should be part of your design?
Iteru [2.4K]

Answer: AES encryption

802.1x

Explanation:

4 0
1 year ago
Sort short_names in reverse alphabetic order.
tangare [24]

lst = short_names.split()

print(sorted(lst,reverse = True))

6 0
2 years ago
Other questions:
  • One main advantage of CD-ROMs is that..
    7·1 answer
  • Which of the following binary (base-2) numbers is LARGEST?
    14·1 answer
  • Write a method called all Less that accepts two arrays of integers and returns true if each element in the first array is less t
    12·1 answer
  • 8. A pattern of being late for work or for appointments is usually
    12·1 answer
  • The countryside presents
    11·1 answer
  • The parallax perspective says that objects that are close up appear to move __________ than far away objects.
    10·1 answer
  • For almost all networks today, including the internet, the communication protocol used is called ____.
    15·1 answer
  • A system administrator is selecting an operating system for use by the company’s research and development team. The team require
    15·1 answer
  • Before measuring resistance of a component, be sure:
    8·1 answer
  • several ways that we commonly use technology today that people couldn't 10 years ago. Are these uses helpful or harmful to socie
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!