Write a Java program that reads the desired number of coin f…
Write a Java program that reads the desired number of coin flips as an input and prints “Heads” or “Tales” randomly for each coin flip. The main method reads the number of coin flips from the user (Assume the input is a value greater than 0) and uses a loop that generates a random number between 0 and 1, passes that number to the method coinFlip, and prints the value returned by the method. The loop is repeated as many times as the number of coin flips entered. The coinFlip method takes a random number (0 or 1) as a parameter and returns the string “Heads” or “Tails” according to the random value received. Assume the value 1 represents “Heads” and 0 represents “Tails”. Ex: If the input is: 3 the output could be: Heads Tails Heads Note: The random number is created in the main() method using the Math.random() method.