4.17 LAB: Flip a coin
Write a program that simulates flipping a coin to makedecisions. The input is how many decisions are needed, and theoutput is either heads or tails. Assume the input is a valuegreater than 0.
Ex: If the input is:
the output is:
For reproducibility needed for auto-grading, seed the programwith a value of 1. In a real program, you would seed with thecurrent time. In that case, every program's output would bedifferent, which is what is desired but can't be auto-graded.
Note: A common student mistake is to seed before each call torandom.randint(). But seeding should only be done once, at thestart of the program, after which random.randint() can be calledany number of times.
Your program must define and call the heads_or_tails() functionthat randomly picks 0 or 1 and returns "heads" or "tails". Assumethe value 0 represents "heads" and 1 represents "tails".
Code in Java please**
4.17 LAB: Flip a coin Write a program that simulates flipping a coin to make decisions. The input is how many decisions
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am