Write a program that simulates tossing a coin. Prompt the user for how many times to toss the coin. Code a method with no parameters that randomly returns either the String "heads"or the string "tails". Call this method in main as many times as requested and report the results. See Example outputs below. Example Outputs How many times should I toss the coin? 1000 Results of 1000 tosses. Heads: 483, tails: 517 How many times should I toss the coin? 1000000 Results of 1000000 tosses. Heads: 500074, tails: 499926
Hello! I need help with the first problem, here are the requirements!
Please use Eclipse if possible! and showing a screenshot of it would also be helpful. Also comments displaying what the code is also very helpful so I understand it. Thank you so much!!!
Assignment Requirements
- Create a new Java Project in your Eclipse workspace named as before, smith3 or jones3 for example.
- Create a package with the very same name as your project name.
- In this one package, write one Java program for each exercise as required below.
- Choose descriptive variable names and identifiers in all programs
1. Write a program that simulates tossing a coin. Prompt the user for how many times to toss the coin. Code a method with no parameters that randomly returns either the String "heads"or the string "tails". Call this method in main as many times as requested and report the results. See Example outputs below.
Example Outputs
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
consider a population where 30% is in poverty. If you randomly sampled 10 people, how many would you expect to be in poverty?