Specification Create a new class in your Unit 1 project call CastingOverloading Write…
- User
Specification Create a new class in your Unit 1 project call CastingOverloading Write each of the methods listed below You may only use Math.random(), math ops, and casting for this assignment. You may not use conditionals.
(14) public static int oneOrZero() //return a 0 or 1 at random
(15) public static int zeroTo99I() //return a random integer from 0 to 99
(16) public static double zeroTo99D() //return a random double from 0 to 99
(17) public static int zeroToN(int n) //return a random integer from 0 to n
(18) public static double zeroToN(double n) //return a random double from 0.0 to n
(19) public static int minToMax(int min, int max) // return a random integer from min to max (exclusive)
(20) public static double minToMax(double min, double max) // return a random double from min to max (exclusive)
- Assistant
Specification
Class Name: CastingOverloading
Methods:
-
public static int oneOrZero()
- Return type: int
- Description: This method generates a random number using Math.random() method and returns either 0 or 1.
- Input: None
- Output: Random number between 0 and 1 (inclusive)
-
public static int zeroTo99I()
- Return type: int
- Description: This method generates a random integer between 0 and 99 (inclusive).
-
- User
Specification Create a new class in your Unit 1 project call CastingOverloading Write each of the methods listed below You may only use Math.random(), math ops, and casting for this assignment. You may not use conditionals.
(14) public static int oneOrZero() //return a 0 or 1 at random
(15) public static int zeroTo99I() //return a random integer from 0 to 99
(16) public static double zeroTo99D() //return a random double from 0 to 99
(17) public static int zeroToN(int n) //return a random integer from 0 to n
(18) public static double zeroToN(double n) //return a random double from 0.0 to n
(19) public static int minToMax(int min, int max) // return a random integer from min to max (exclusive)
(20) public static double minToMax(double min, double max) // return a random double from min to max (exclusive) give me code
- Assistant
Here is the code for the CastingOverloading class with the specified methods:
java