Question: Make a function that does the following: Generates a random number from the interval [0, 1000]. Note: Remember that Math.random() outputs a random number from
Make a function that does the following:
Generates a random number from the interval [0, 1000].
Note: Remember that Math.random() outputs a random number from [0,1]. Do the correspondingmathematical operations to extend the interval to [0,1000].
Prints the generated number using the string concatenation. The printing should have the followingformat:
Randomly generated number: [insert number here]
Displays the ones, tens, and hundreds digit of that number. Use string operations to display thenumbers. The printing should have the following format:
Breakdown: [hundred], [tens], [ones]
Sample output:
Randomly generated number: 458
Breakdown: 400, 50, 8
Note: There are two ways for this. The first is by using mathematical operations to separate theones, tens, and hundreds. The second way is to treat the randomly generated number as string and access thecharacters individually.
Step by Step Solution
3.49 Rating (152 Votes )
There are 3 Steps involved in it
public class RandomNumberGenerator public static void generateAndPrintNumber Ge... View full answer
Get step-by-step solutions from verified subject matter experts
