Homework 3

 

A Game of Chance (50 PTS) 1.  This will require a pretty major modification/simplification of the Craps.java we did in class. 

Consider a game where a single coin is tossed until the first head appears.

-  The house wins if the first head appears on an odd numbered toss
   1, 3, 5, 7 ...

-  The player/user wins if the first head appears on an even numbered toss
   2, 4, 6, 8 ...

You want to create a button to appear in an applet that gives the player the opportunity to toss the coin until the first head appears and a winner is determined.  You also want the program to

  • tell the user who wins, the player or the house in the status bar. 
  • report the number of times the house has won in this particular playing session and
  • how many times the player has won in this particular session
  • the overall percentage of times the player is winning
  • display the sequence of tosses until the first head appears
  • the toss number

 

Adding Two Matrices (50 PTS) 2.  Create a GUI that can be used for the following

  • receive input for two different 2 x 3 matrices
    • work with real numbers
    • trap for non-numeric inputs and
      • give an error message that tells them you are converting them each to 0.0
      • convert them to 0.0
  • compute their sum and display it