Course Solutions Uncategorized (Solved) : 6 Examine Flipcoinjava Execute Following Program Observe Random Number Chance Generated Ch Q36545279 . . . .

(Solved) : 6 Examine Flipcoinjava Execute Following Program Observe Random Number Chance Generated Ch Q36545279 . . . .

 

6.

• Examine FlipCoin.java:

– Execute the following program and observe the random numberthat chance generated.

– If chance < 0.5, record the result as “heads”; else recordthe result as “tails.”

– Repeat this many time.

import java.util.Random;

public class FlipCoin {

    public static void main(String[] args) {

        // 50% chance heads,50% chance tails

        Random rand = newRandom();

        double chance =rand.nextDouble();

       System.out.println(chance);

        }

    }

Exercise 2

• Examine RockPaperScissor.java.

– Perform the following:

– Simulate the RockPaperScissor game by generating a randominteger number in the range of 0 to 3.

– Compare the generated number with the following numbers:

– if number=0 : “rock”

– if number=1: “paper”

– if number=2: “scissors”

– Record the result

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

(Solved) : Change Angular Momentum System Equal O Zero O Net External Torque O Net Internal Torque O Q33298526 . . . .(Solved) : Change Angular Momentum System Equal O Zero O Net External Torque O Net Internal Torque O Q33298526 . . . .

<br/><img src="https://media.cheggcdn.com/media%2F246%2F24675da7-9b9b-46ea-b6c4-422ffca88356%2Fimage.png" alt="The change in angular momentum of a system is equal to O zero O the net external torque. O the net internal torque. O the sum of all