Provide the code for a class called Coin.java that implements the main method provided below.
public static void main(String [] args)
{
Coin toss = new Coin();
for (int x = 0; x < 1000; x++)
toss.flip();
Coin.results();
}//end main
When the program runs, the following random output should be produced: (numbers will vary as are random)
Heads: 494
Tails: 506
Program specific requirements:
- Style is require but comments are NOT required.
- Include appropriate import statements for your file.
- Utilize a constant class array to hold "Heads" and "Tails"
- Declare a class ArrayList called flips that will hold integer values, 0 for heads and 1 for tails
- Create a flips method that performs the following:
- Initializes an instance of the Random class and a random variable
- Stores a random variable either 0 or 1
- Store the random number in the flips ArrayList
- Create a results method that performs the following:
- Declare variable to hold number of heads flipped
- Utilize a for loop to iterate through the ArrayList (do NOT hard code the size here)
- For each iteration, increment the result from the ArrayList into a variable called heads
- Output the number of Heads using the constant array for the "Heads" heading along with the number of heads flipped
- Output the number of Tails using the constant array for the "Tails" heading along with the number of