Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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 showFace that returns a 0 if 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: nickel (incoino: if (nickel.showFace() == 0) { System.out.println("Heads up"); } else { System.out.println("Tails up!') }Use the following formula to randomize a coin flip (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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Watson Watson

5th Edition

0471715360, 978-0471715368

More Books

Students also viewed these Databases questions

Question

LO2 Explain the nature of the psychological contract.

Answered: 1 week ago

Question

LO1 Discuss four different views of motivation at work.

Answered: 1 week ago