Question: Java programming 5th edition 3 java files. Copy Java programs to create the CashRegister class (p.521), the Dispenser class (p. 525), and the CandyMachine client
Java programming 5th edition 3 java files. Copy Java programs to create the CashRegister class (p.521), the Dispenser class (p. 525), and the CandyMachine client (pp.527 - 530), which includes methods for main(), showSelection(), sellProduct(), and displayAmounts(). The displayAmounts() method is not in the book, but should display the current balance in the cash register and the counts for all 4 items in the dispenser.
The main method should: use the default constructor to instantiate the CashRegister and the following numbers to instantiate the 4 Dispensor items.
Item Number of Items Cost
candy 100 50
chips 80 65
gum 75 45
cookies 55 85
call the diplayAmounts method to display the intitial amounts
run each menu choice at least once and a couple of them at least one additional time, be sure to test the cash register in different ways (enter money in different numbers of increments)
call the displayAmounts method again to make sure the number of items is being subtracted correctly in the Dispenser
output:
Coins currently in cash register: 500
Amount of candy currently in dispenser: 100
Amount of chips currently in dispenser: 80
Amount of gum currently in dispenser: 75
Amount of cookies currentlly in dispenser: 55
*********Welcome to Shelly's Candy Shop************
To select an item, enter
1 for Candy
2 for Chips
3 for Gum
4 for Cookies
9 to Exit
1
Please deposit 50 cents: 50
Collect your item at the bottom and enjoy.
********Welcome to Shelly's Candy Shop********
To select an item, enter
1 for Candy
2 for Chips
3 for Gum
4 for Cookies
9 to Exit
2
Please deposit 65 cents: 50
Please deposit 15 cents: 15
Collect your item at the bottom and enjoy.
*********Welcome to Shelly's Candy Shop************
To select an item, enter
1 for Candy
2 for Chips
3 for Gum
4 for Cookies
9 to Exit
3
Please deposit 45 cents: 10
Please deposit 35 cents: 5
Please deposit 30 cents: 30
Collect your item at the bottom and ejoy.
*********Welcome to Shelly's Candy Shop************
To select an item, enter
1 for Candy
2 for Chips
3 for Gum
4 for Cookies
9 to Exit
4
Please deposit 85 cents: 85
Collect your item at the bottom and enjoy.
*********Welcome to Shelly's Candy Shop************
To select an item, enter
1 for Candy
2 for Chips
3 for Gum
4 for Cookies
9 to Exit
1
Please deposit 50 cents: 25
Please deposit 25 cents: 25
Collect your item at the bottom and enjoy.
*********Welcome to Shelly's Candy Shop************
To select an item, enter
1 for Candy
2 for Chips
3 for Gum
4 for Cookies
9 to Exit
3
Please deposit 45 cents: 45
Collect your item at the bottom and enjoy.
*********Welcome to Shelly's Candy Shop************
To select an item, enter
1 for Candy
2 for Chips
3 for Gum
4 for Cookies
9 to Exit
9
Coins currently in cash register: 840
Amount of candy currently in dispenser: 98
Amount of chips currently in dispenser: 79
Amount of gum currently in dispenser: 73
Amount of cookies currently in dispenser: 54
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
