Make sure you have read and understood.docx

Make sure you have read and understood.docx - ,and .,please...

This preview shows page 1 - 3 out of 9 pages.

Make sure you have read and understood                  both   modules A   and   B   this week, and                  module 2R - Lab Homework Requirements before submitting this assignment. Hand in only one program, please.   For this assignment you will have to investigate the use of the Java random number generator  function, Math.random().    You can find this in the text or using the online resources given in the  lectures. A Slot Machine Simulation Understand the Application What it Looks Like to the User The program will loop, asking the user for a bet amount from 0 to 50 (assume dollars, you can  use   ints   or   longs).    If the user types a 0 that means she wants to quit.    Otherwise, accept the  amount as their bet and simulate a   slot machine pull.    Your program will print out a line that  looks like a slot machine result containing three strings.    Some examples are:     BAR    7    BAR,   7     7    cherries,   cherries    BAR    space,   space    BAR    BAR, or   cherries    cherries    BAR.                  Each of the three positions in the string could be one of the following:    "BAR", "7",  "cherries" or "space".                    Each of the three output positions must be generated by your program randomly with  probabilities (defined, as always, by   final statics): o        BAR                                  (38%) o        cherries        (40%) o        space                      (7%) o        7                                          (15%) o        Therefore,   cherries      should be the most frequent symbol seen and   space   or   7the least  frequent.                  The following combinations should pay the bet as shown (note   ORDER MATTERS): o        cherries    [not cherries]    [any]   pays   5   ×   bet   (5   times   the bet)
Image of page 1
o        cherries    cherries    [not cherries]   pays   15   ×   bet o        cherries    cherries    cherries   pays   30   ×   bet o        BAR    BAR    BAR   pays   50   ×   bet o        7    7    7   pays   100   ×   bet                  After the pull, display the three strings regardless of the outcome.    If the user did not win,  tell him/her "Sorry, you lose."    If he won, pay him by displaying his winnings (his original  bet   times   the winning factor from the above table).    Then, repeat the whole process by  requesting another bet amount.
Image of page 2

Want to read all 9 pages?

Image of page 3

Want to read all 9 pages?

You've reached the end of your free preview.

Want to read all 9 pages?

  • Fall '08
  • Staff
  • cherries, cherries  cherries, cherries  cherries  BAR, cherries  cherries  cherries

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern