Question: Java Generating non-repeating random numbers using a combination of repetition and selection . Suppose your generating random numbers for ace and four other people named
Java
Generating non-repeating random numbers using a combination of repetition and selection.
Suppose your generating random numbers for ace and four other people named first, second, third, and fourth. These random numbers range from 0-4 and it must not repeat. Each number represents a role.
Print out the corresponding role.
| Number | Role |
| 0 | Teacher |
| 1 | Bus driver |
| 2 | Coach |
| 3 | Writer |
| 4 | Student |
Example output:
| 1st time | 2nd time | 3rd time | 4th time | 5th time | |
| Ace | 0 | 3 | 4 | 2 | 2 |
| First | 3 | 2 | 0 | 3 | 4 |
| Second | 2 | 0 | 1 | 0 | 1 |
| Third | 4 | 4 | 3 | 1 | 0 |
| Fourth | 1 | 1 | 2 | 4 | 3 |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
