HighLow - /* This program lets the user play HighLow, a...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/* This program lets the user play HighLow, a simple card game that is described in the output statements at the beginning of the main() routine. After the user plays several games, the user's average score is reported. */ * public class HighLow { p public static void main(String[] args) { TextIO.putln("This program lets you play the simple card game HighLow."); TextIO.putln("A card is dealt from a deck of cards. You have to predict"); TextIO.putln("whether the next card will be higher or lower. Your score"); TextIO.putln("in the game is how many correct predictions you make before"); TextIO.putln("you guess wrong."); TextIO.putln(); int gamesPlayed = 0; // Number of games user has played. int sumOfScores = 0; // The sum of all the scores from all the // games played. double averageScore; // Average score, computed by dividing // sumOfScores by gamesPlayed. boolean playAgain; // Record user's response when user is asked // whether he wants to play another game. do {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

HighLow - /* This program lets the user play HighLow, a...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online