Java Reference
In-Depth Information
΢΢ Exercise P12.6. Write a 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 selects a product from a list of available
products, adds coins, and either gets the product or gets the coins returned
if insufficient money was supplied or if the product is sold out. The
machine does not give change if too much money was added. Products can
be restocked and money removed by an operator. Follow the design
process that was described in this chapter. Your solution should include a
class VendingMachine that is not coupled with the Scanner or
PrintStream classes.
΢΢΢ Exercise P12.7. Write a program to design an appointment calendar. An
appointment includes the date, starting time, ending time, and a
description; for example,
Dentist 2007/10/1 17:30 18:30
CS1 class 2007/10/2 08:30 10:00
Supply a user interface to add appointments, remove canceled
appointments, and print out a list of appointments for a particular day.
Follow the design process that was described in this chapter. Your
solution should include a class AppointmentCalendar that is not
coupled with the Scanner or PrintStream classes.
΢΢΢ Exercise P12.8. Airline seating. Write a program that assigns seats on an
airplane. Assume the airplane has 20 seats in first class (5 rows of 4 seats
each, separated by an aisle) and 90 seats in economy class (15 rows of 6
seats each, separated by an aisle). Your program should take three
commands: add passengers, show seating, and quit. When passengers are
added, ask for the class (first or economy), the number of passengers
traveling together (1 or 2 in first class; 1 to 3 in economy), and the
seating preference (aisl e or window in first class; aisle, center, or
window in economy) . Then try to find a match and assign the seats. If no
match exists, print a message. Your solution should include a class
Airplane that is not coupled with the Scanner or PrintSream
classes. Follow the design process that was described in this chapter.
581
582
Search WWH ::




Custom Search