Write a program that prompts for an integer input. If the input is less than 1,
ID: 3651882 • Letter: W
Question
Write a program that prompts for an integer input. If the input is less than 1, re-prompt and re-collect from the user. When the input is valid, it represents the number of times to flip a coin. A properly balanced coin has a 50% chance of producing heads OR tails each time it is tossed. Your program should simulate a coin being tossed as many times as was input by the user. When the program is done, output the total number of heads and the total number of tails produced as well as the percentages.Explanation / Answer
import java.util.Scanner; public class CoinToss { static int times; static int heads=0; static int tails=0; public static void main(String[] args) { System.out.println("Enter the times you want to flip the coin"); Scanner input=new Scanner(System.in); times=input.nextInt(); System.out.println("Its Processing....... Please Wait & do't press any key"); for(int i=1;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.