Question: create a constructor public Coin (); with faceUp=1; or faceUp=0; make sure public void flipCoin; faceUp= (int) (Math.random()+0.5);, output should always equal heads up! Create

Create a Coin class that includes a variable faceUp that stores either a 0 for heads up or 1 for tails up, an accessor method named showEace that returns a bit the coin is heads up or a 1 if the coin is tails up, and a modifier method named flipcoin that assigns a random integer between 0 and 1 inclusive, to the variable face un dont include a return method for flipcoin Test the class with the following client code public static void main(String args) { Coin nickel = new Coin: nickelfinolot (nickelshowEace0 =0) { System.out.println("Heads up")) else { System.out.print Tils up")} Use the following formula to randomize a coin tip (it will return a random integer between 0 and 1) (int) (Math.random() *0.5)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
