Assignment 5

Tossing a coin has two possibilities, heads or tails. We can represet this in a boolean where heads is true and a false is tails. A method can be written to handle this -

public boolean coinToss()

It will randomly choose between heads and tails and will return true for heads and false for tails.

Random numbers are generated using the method Math.rand() which will generate a number from 0 to 1. You must use this function in order to generate the coin toss. Some help -

 

 
Basics
Menu
Search