Using the Coin class defined in this chapter, design and imple- ment a driver class called F1ipRace whose main method creates two Coin objects, then continually flips them both to see which coin first comes up heads three flips in a row. Continue flipping the coins until one of the coins wins the race, and consider the possibility that they might tie. Print the results of each turn, and at the end print the winner and total number of flips that were equired.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Using your Eclipse / Java integrated development environment (IDE), code a solution to PP 5.6 from page 250 of your text book. Note that you should use the Coin java file included here without making any changes to it. the Coin java file is here

You should submit the Coin java file (with no changes) and a UML file created using the Violet UML Editor in html format.

//********************************************************************
// Coin.java            Authors: Lewis & Loftus
//
// Represents a coin with two sides that can be flipped.
//********************************************************************

public class Coin
{
private final int HEADS = 0;
private final int TAILS = 1;

private int face;

//-----------------------------------------------------------------
// Sets up the coin by flipping it initially.
//-----------------------------------------------------------------
public Coin ()
{
flip();
}

//-----------------------------------------------------------------
// Flips the coin by randomly choosing a face value.
//-----------------------------------------------------------------
public void flip ()
{
face = (int) (Math.random() * 2);
}

//-----------------------------------------------------------------
// Returns true if the current face of the coin is heads.
//-----------------------------------------------------------------
public boolean isHeads ()
{
return (face == HEADS);
}

//-----------------------------------------------------------------
// Returns the current face of the coin as a string.
//-----------------------------------------------------------------
public String toString()
{
String faceName;

if (face == HEADS)
faceName = "Heads";
else
faceName = "Tails";

return faceName;
}
}

and page 250 is attached below

Modify the solution to the previous project so that the user can
Write a program that determines and prints the number of odd,
even, and zero digits in an integer value read from the keyboard.
using an appropriate sentinel value. Validate each input value to
250
CHAPTER 5 Conditionals and Loops
PP 5.2
program
evaluate multiple years. Allow the user to terminate the
ensure it is greater than or equal to 1582.
PP 5.3
Write a program that plays the Hi-Lo guessing game with Dum
bers. The program should pick a random number between 1
and 100 (inclusive), then repeatedly prompt the user to guess
the number. On each guess, report to the user that he or she
is correct or that the guess is high or low. Continue accepting
guesses until the user guesses correctly or chooses to quit. Use
a sentinel value to determine whether the user wants to quit.
Count the number of guesses and report that value when the user
guesses correctly. At the end of each game (by quitting or a cor-
rect guess), prompt to determine whether the user wants to play
again. Continue playing games until the user chooses to stop.
Create a modified version of the PalindromeTester program so
that the spaces, punctuation, and changes in uppercase and low-
ercase are not considered when determining whether a string is a
palindrome. Hint: These issues can be handled in several ways.
Think carefully about your design.
Using the Coin class defined in this chapter, design and imple-
ment a driver class called F1ipRace whose main method creates
two Coin objects, then continually flips them both to see which
coin first comes up heads three flips in a row. Continue flipping
the coins until one of the coins wins the race, and consider the
possibility that they might tie. Print the results of each turn, and
at the end print the winner and total number of flips that were
required.
PP 5.4
VideoNote
Developing a solution
of PP 5.4.
PP 5.5
PP 5.6
Write a program that plays the Rock-Paper-Scissors game against
the
PP 5.7
When played between two people, each person
computer.
picks one of three options (usually shown by a hand gesture) at
the same time, and a winner is determined. In the
beats Scissors, Scissors beats Paper, and Paper beats Rock. The
program should randomly choose one of the three options (with-
out revealing it), then prompt for the user's selection. At that
point, the program reveals both choices and prints a statement
indicating if the user won, the computer won, or if it was a tie.
Continue playing until the user chooses to stop, then print the
number of user wins, losses, and ties.
game,
Rock
Transcribed Image Text:Modify the solution to the previous project so that the user can Write a program that determines and prints the number of odd, even, and zero digits in an integer value read from the keyboard. using an appropriate sentinel value. Validate each input value to 250 CHAPTER 5 Conditionals and Loops PP 5.2 program evaluate multiple years. Allow the user to terminate the ensure it is greater than or equal to 1582. PP 5.3 Write a program that plays the Hi-Lo guessing game with Dum bers. The program should pick a random number between 1 and 100 (inclusive), then repeatedly prompt the user to guess the number. On each guess, report to the user that he or she is correct or that the guess is high or low. Continue accepting guesses until the user guesses correctly or chooses to quit. Use a sentinel value to determine whether the user wants to quit. Count the number of guesses and report that value when the user guesses correctly. At the end of each game (by quitting or a cor- rect guess), prompt to determine whether the user wants to play again. Continue playing games until the user chooses to stop. Create a modified version of the PalindromeTester program so that the spaces, punctuation, and changes in uppercase and low- ercase are not considered when determining whether a string is a palindrome. Hint: These issues can be handled in several ways. Think carefully about your design. Using the Coin class defined in this chapter, design and imple- ment a driver class called F1ipRace whose main method creates two Coin objects, then continually flips them both to see which coin first comes up heads three flips in a row. Continue flipping the coins until one of the coins wins the race, and consider the possibility that they might tie. Print the results of each turn, and at the end print the winner and total number of flips that were required. PP 5.4 VideoNote Developing a solution of PP 5.4. PP 5.5 PP 5.6 Write a program that plays the Rock-Paper-Scissors game against the PP 5.7 When played between two people, each person computer. picks one of three options (usually shown by a hand gesture) at the same time, and a winner is determined. In the beats Scissors, Scissors beats Paper, and Paper beats Rock. The program should randomly choose one of the three options (with- out revealing it), then prompt for the user's selection. At that point, the program reveals both choices and prints a statement indicating if the user won, the computer won, or if it was a tie. Continue playing until the user chooses to stop, then print the number of user wins, losses, and ties. game, Rock
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education