Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1 (5 points) First player: Rolling 2 random dice Write code using Random to simulating rolling two random dice. You should get two random

image text in transcribed
image text in transcribed
Part 1 (5 points) First player: Rolling 2 random dice Write code using Random to simulating rolling two random dice. You should get two random values from 1 to 6 and store them in variables die1 and die2. Print those variables like this: First player's roll is 2 4 Since it is using Random, it should get different results every time you run it. Run your program several times to make sure you can get all values from 1 to 6. Part 2 (5 points) Swaping so first die is the higher value Use an if statment to compare the two dice, and, if necessary, swap the values in die1 and die2. Note: to swap 2 values you will need a third temporary variable to hold one of the values and 3 assignment statements (like: temp = a; a b; b = temp;). Move your printing code to the end of the program and again test it several times. It should now look like this: First player's roll is 4 2

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

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions