Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

**Java Programming In this lab you will generate a pseudo-random number between

ID: 3922820 • Letter: #

Question

**Java Programming

In this lab you will generate a pseudo-random number between 1 and 100, group the number chosen into one of four groups, and test to see if the number is a winner.

Requirements:

This program will need to do the following:

When the program is run, three column headings (called Rand, Group, and Winner) will be printed

Your program will loop twenty-five times.

On each loop:

A random number will print in the first column. You should read https://docs.oracle.com/javase/7/docs/api/java/lang/Math.html (Links to an external site.) to understand how the random function works. Realize that you will need to convert the random number generated by Java into a value between 1 and 100.

A group number will print in the second column. The group should be assigned as follows:

Group 1: 1-25

Group 2: 26-50

Group 3: 51-75

Group 4: 76-100

A  word, either "true" or "false" will print in the third column using the %b format specifier to indicate whether the random number generated is a winner. Winners should be only from Group 2 if the number is even. You must use a logical operator to perform this test.

All of the columns should be evenly spaced and align right.

5 Bonus points: Add a fourth column called Grand Prize winner that prints two asterisks in the center of the column if the random number from column one is from Group 3 and is a double digit (i.e. 11, 22, 33, 44,...). Make sure you focus your attention on getting the lab perfect based on the rubric before attempting the bonus points

Explanation / Answer

Please find the required program along with its output. Please see the comments against each line to understand the step.

-------------------------------------

OUTPUT:

Rand   Group   Winner   Grand Prize winner
48           2   true      
39           2          
83           4          
26           2   true      
19           1          
20           1          
33           2          
78           4          
54           3          
81           4          
45           2          
69           3          
3           1          
21           1          
59           3          
47           2          
85           4          
55           3 **
18           1          
31           2          
52           3          
4           1          
82           4          
59           3          
21           1