Write a java program that simulates a vending machine. Products can be purchased by inserting coins with a value at least equal to the cost of the product. A user select a product from a list of available products, add coins, and either gets the products or gets the coins returned. The coins are returned if insufficient money was supplied or if the product it's sold out. The machine does not give change if too much money was added. Products can be restocked and money remove by an operator. Your solution should include a class VendingMachine that is not coupled with the Scanner or PrintStream classes. Runtime output S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit a Description: Cookie Price: 1.50 Quantity: 3 S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit A Description: Candy Price: 1.25 Quantity: 2 S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit S Cookie @ $1.50 Candy @ $1.25 S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit b A) Cookie @ $1.50 B) Candy @ $1.25 a Insufficient money S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit i A) nickel @ 0.05 B) dime @ 0.1 C) quarter @ 0.25 D) dollar @ 1.0 d S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit i A) nickel @ 0.05 B) dime @ 0.1 C) quarter @ 0.25 D) dollar @ 1.0 d S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit b A) Cookie @ $1.500 B) Candy @ $1.25 a Purchased: Cookie @ $1.50 Your change: $0.50 S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit s Cookie @ $1.50 Candy @ $1.25 S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit b A) Cookie @ $1.50 B) Candy @ $1.25 b Insufficient money S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit i A) nickel @ 0.05 B) dime @ 0.1 C) quarter @ 0.25 D) dollar @ 1.0 d S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit i A) nickel @ 0.05 B) dime @ 0.1 C) quarter @ 0.25 D) dollar @ 1.0 c S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit b A) Cookie @ $1.50 B) Candy @ $1.25 b Purchased: Candy @ $1.25 S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit r Removed: $2.75

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Write a java program that simulates a vending machine. Products can be purchased by inserting coins with a value at least equal to the cost of the product. A user select a product from a list of available products, add coins, and either gets the products or gets the coins returned. The coins are returned if insufficient money was supplied or if the product it's sold out. The machine does not give change if too much money was added. Products can be restocked and money remove by an operator. Your solution should include a class VendingMachine that is not coupled with the Scanner or PrintStream classes.

Runtime output

S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit
a
Description:
Cookie
Price:
1.50
Quantity:
3

S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit
A
Description:
Candy
Price:
1.25
Quantity:
2

S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit
S
Cookie @ $1.50
Candy @ $1.25

S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit
b
A) Cookie @ $1.50
B) Candy @ $1.25
a
Insufficient money

S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit
i
A) nickel @ 0.05
B) dime @ 0.1
C) quarter @ 0.25
D) dollar @ 1.0
d

S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit
i
A) nickel @ 0.05
B) dime @ 0.1
C) quarter @ 0.25
D) dollar @ 1.0
d

S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit
b
A) Cookie @ $1.500
B) Candy @ $1.25
a

Purchased: Cookie @ $1.50
Your change: $0.50
S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit
s

Cookie @ $1.50
Candy @ $1.25
S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit
b

  1. A) Cookie @ $1.50
    B) Candy @ $1.25
    b

Insufficient money
S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit
i

  1. A) nickel @ 0.05
    B) dime @ 0.1
    C) quarter @ 0.25
    D) dollar @ 1.0
    d

S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit
i
A) nickel @ 0.05
B) dime @ 0.1
C) quarter @ 0.25
D) dollar @ 1.0
c

S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit
b
A) Cookie @ $1.50
B) Candy @ $1.25
b

Purchased: Candy @ $1.25
S)how products I)nsert coin B)uy A)dd product R)emove coins Q)uit
r

Removed: $2.75

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 7 steps with 1 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education