Assignment 06

The Troubled Vending Machine

Specifications: In general, the machine will work in three phases: 1) when an option is chosen, it will output a message stating "You have chosen XXX"; and then 2) it will state the cost and ask for and handle payment; and finally 3) output what you actually receive "Here is your XXX". Here is a list of modifications to the vending machine described in hw 4 that you will implement in this assignment:

And for this iteration of hw 4, there are changes in the specifications. The vending machine has changed and your code is to reflect those changes. Read on!!

Background: hw4Foreground: Your program this time around is to rewrite hw 4 using functions. But this time around, YOU decide on the functions to use. You are to use good judgement (and you will be graded on that judgement) on how to break down the big program into smaller units - functions. Make good decisions!

Due: Friday, March 9, 2018 at noon 100 ptsYou know how to submit; do it in the usual way. However, this time you will submit multiple files for this programming project. The cssubmit script will work as usual, picking up all .cpp and .h files in the current directory. So, make sure you have created a separate directory for your hw 6 program. Do not create sub-directories in the hw6 directory.

At the point of entering a choice from the menu:

  • There is a 80% chance that you will get what you chose.

  • With a 20% chance, when any option is chosen (including quit), the machine will change your choice to another (different) valid choice. As an example, you select carrots, but the machine states you chose kale and charges for kale. Bummer. Payment phase should continue as if you chose the substituted item.

  • There is a 55% chance payment works correctly.

  • With a 45% chance, any time that you input (enter) more than the required money, the machine will give no change and output "Sorry, no change for you!"

At the point of receiving the item (output of the message "here's your xxxx")

  • 50% of the time, everything works correctly.

  • There is a 25% chance that they get NOTHING (like most vending machines!) and the output message will be "Nothing for you, sucker! I don't care if you paid"

  • There is a 15% chance that one of the following (with equal likelihood) is output along with the indicated message:

    • a dead mouse - "A dead mousie for you ... been in there for a while"

    • a circuit board from the machine - "a circuit board ... I have a small internal fire here! Run! What are you standing there for??"

    • a Dylan5 doll - "A Dylan5 doll....ZZZZZZZ"

  • 10% of the time, you get what you paid for but you get 7 of them. Cool!! The output statement should reflect that.

Detail(s): Every time a user makes a choice, the chance that they get a mouse, a doll, or a circuit board and a fire (initially 15%), actually increases by 5% (getting old is hell) and the chance of the machine working properly (50%) decreases by that 5% until normal operation no longer happens and funny output reaches 65% of the time. Also, the machine has an attitude.

At the point of paying for the item:

That will be implemented by limiting the user to 10 choices. After the 10th choice (attempting the 11th use), the machine will output "Get lost, Pal! You've gotten enough of me already."

Note: We have given you perfect opportunities for using static variables. You might want to consider that option! Also, be sure to include documentation for all your functions.

When you submit: seed your rng with 5. Then, make the following vending choices with accompanying inputs:

  • enter .08 for meta-rate

  • choose opt 1 and enter $2

  • choose opt 2 and enter $2

  • choose opt 3 and enter $1

  • choose opt 4 and enter $3

  • choose opt 5 and enter $2

  • choose opt 6 and enter $2

  • choose opt 7 and enter $2

  • choose opt 8 and enter $1

  • choose opt 1 and enter $5

  • choose opt 2 and enter $1, then $0.50, then $3

  • choose opt 3 and enter the correct amount

  • quit, if you haven't already been rejected by the machine

As always, if you have issues, just ask your instructor.