Answer:
import java.util.Scanner;
public class num9 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("How many decisions are needed");
int dec = in.nextInt();
for(int i =0; i<dec; i++){
if(Math.random()<0.5){
System.out.print("Heads ");
}
else{
System.out.print("Tails ");
}
}
}
}
Step-by-step explanation:
The Program is implemented in Java as required
Use scanner class to receive and save the variable decisions that indicates the number of times for the tosin of the coin
Use a for loop that will iterate from 0 to the number of times entered by the user
Within the for loop, use Java's Math.random method to randomly generate numbers
use an if condition to determine the output of Heads or Tails depending on the random number generated
see code and output attached