$25
Overview
Whether you are working a nine-to-five job or running from class to class, there is one machine that is in all our lives – the vending machine. These wonderful devices allow us to put in a few coins, select and item, and get what we want/need.
Vending machines vary from food to school supplies. So, the device is quite universal. For this lab, you get to create your own virtual vending machine.
Your program will display a menu of items, input the amount of cents, input their choice and, then, output their selection and their change.
Have fun!
You don't have to create a vending machine using stuff you find on campus. Use your imagination!
Cat items
Wizard items Cartoon items • etc....
Example
Your solution doesn't have to look exactly like the example below. The user's input is printed in blue. The data outputted from your calculations is printed in red. You don’t have to make the text that color in your program.
You don't have to worry about input validation. If they enter a wrong amount, don't worry about what will happen.
Fluff-a-matic Vending machine
Cat Nip (85 cents)
String (25 cents)
Bouncy Ball (60 cents)
Cat Snacks (42 cents)
Enter money: 100
Your selection: 3
Bouncy Ball (60 cents) Your change is 40 2
Tips
The Data Section
Create strings for each item in your vending machine.
Create a table of those addresses (to lookup the purchased item).
Also create a table of costs.
Work in your program in parts – incremental design!
Example
The following contains an example of how to make an table of addresses (which are quads) and table of values (also quads). Please feel free to change your labels.
CatNip:
.ascii "1. Cat Nip (85 cents)\n\0"
String:
.ascii "2. String (25 cents)\n\0"
…
Items:
.quad CatNip
.quad String
…
Costs:
.quad 85
.quad 25
…
Reading Integers
The CSC 35 Library has a subroutine called "ScanInt" that will read a value from the keyboard and store it into %rcx. This is equivalent to the Java Scanner class method "nextInt".
call ScanInt #rcx = scanner.nextInt();
Requirements
Display a menu of items and costs. You must have (at least) three. Make sure to also print a name for your vending machine.
Input how much money they entered
Input their selection
Output the item they bought to the screen. You must use a table.
Output their change to the screen. You must use a table to look up the cost.