Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Simulating a dice ro11, values between 16 Random gen = new Random (); ht diceRoll = gen.nextint (7); System.out.println(Dice rol1; + diceRoll); 3witch (diceRol1

image text in transcribed
Simulating a dice ro11, values between 16 Random gen = new Random (); ht diceRoll = gen.nextint (7); System.out.println("Dice rol1; " + diceRoll); 3witch (diceRol1 z 2) ( case 0: System.out.println ("You rolled an odd number. "); break; case 1: System.out.println("You rolled an even number. "); break; For the code above: 1. What is the program trying to do? (5 points) 2. Are there any problems that you notice in this code? What are they? (10 points) 3. If there are issues, fix them and submit the fixed code in Lab5_bonus.java (15 points) 4. After fixing your code, within the switch statement, if the number is odd, create another random number within the range 0 to 50 . Then first multiple this random number to the diceRoll then add it. If the result of this operation is divisible by 3, print "I earned the bonus points" otherwise print "I still earned the bonus points". (20 points)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions