Question: The Project Create a program (CoinFlip.java) that: Creates 2 int arrays to store coin flip data from two different coins Simulate a coin flip (0=

The Project

Create a program (CoinFlip.java) that:

Creates 2 int arrays to store coin flip data from two different coins

Simulate a coin flip (0= heads, 1 = tails) 1000 times.( you can use Math.Random() or a Random generator)

gen.nextInt(2);

(int)(Math.random()*2);

Evaluate if the first flip of each coin through the 1000th flip to determine if:

Coin1 flip 1 vs Coin2 flip 1

Coin1 flip 2 vs Coin2 flip 2

Coin1 flip 1000 vs Coin2 flip 1000

Both equals heads

Both equals tails

Have different values

Print out the total counts of the above three

THEN

Evaluate the first flip of the first coin to the last flip of the second and repeat until all flips have been covered, i.e.:

Coin1 flip 1 vs Coin2 flip 1000

Coin1 flip 2 vs Coin2 flip 999

Coin1 flip 1000 vs Coin2 flip 1

Both equals heads

Both equals tails

Have different values

Print out the total counts of the above three

You're not done yet!

Now repeat what you did above but use a 2-D array instead of 2 two separate arrays!

What I have Done

import java.util.*;

public class CoinFlip {

public static void main(String[] args) {

//Coin1

Random coin1 = new Random();

int flip = coin1.nextInt(2);

if (flip == 1){

System.out.println("Coin 1 is: Heads");

}else {

System.out.println("Coin 1 is: Tails");

}

//Coin2

Random coin2 = new Random();

int flip1 = coin2.nextInt(2);

if (flip1 == 1){

System.out.println("Coin 2 is: Heads");

}else {

System.out.println("Coin 2 is: Tails");

}

}

}

I'm not exactly sure what to do next.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!