1. /*LuckySevens.Java
  2. simulates the game of LucySevens until all funds are depleted.
  3. 1) Rules:
  4. Roll two dice
  5. if the sum equals 7, win 4$ else lose 1$
  6. 2) The inputs are:
  7. the amount of money the user is prepared to lose.
  8. 3) Computation:
  9. uses a Dice Class that genertaies a random number
  10. loop until the funds are depleted
  11. count number of rolls
  12. keep track of the Max amount
  13. 4) The outputs are:
  14. the number of rolls it takes to deplete the funds
  15. the max amount
  16. */
  17.  
  18. import java.util.Scanner;
  19.  
  20.  
  21. public class LuckySevens {
  22. public static void main(String[] args) {
  23. Scanner reader = new Scanner(system.in);
  24.  
  25. int
  26. dollars, //initail number of dollars (input)
  27. count, //number of rolls to reach depletion
  28. maxDollars, //maximum amount held by the gambler
  29. countAtMax; //count when the maximum is achieved
  30. Dice die1 = new Dice();
  31. Dice die2 = new Dice();
  32. die1.roll();
  33. die2.roll();
  34.  
  35.  
  36.  
  37. // Request the input
  38. System.out.print("How many dollars do you have? ");
  39. dollars = reader.nextInt();
  40.  
  41. // Initalize Variables
  42. maxDollars = dollars;
  43. countAtMax = 0;
  44. count = 0;
  45.  
  46. //loop until the money is gone
  47. while (dollars > 0) {count++;
  48.  
  49. private int side;
  50. public Dice()(
  51. side = 1; //set side to any value from 1 - 6)
  52. public int getCurrentSide()( return side;
  53. )
  54. }
  55. }