CIT 590 Assignment 2: Coke Machine
Spring 2009, David Matuszek

Purposes of this assignment:

General idea of the assignment:

Simulate the operation of a Coke machine. This machine offers Coke, Coke Zero, and Caffeine-free Diet Coke. All drinks cost $1 (100 cents). The machine does not take dollar bills or pennies, but it does take nickels, dimes, and quarters. When enough money has been entered, a drink may be selected, and any change is returned (the specific coins are listed).

Only coins in denominations of 5, 10, and 25 cents are accepted. Any other denomination (33 cents, 50 cents, etc.) is rejected and returned.

More than one drink may be purchased (that is, the program doesn't quit after selling one drink).

There is no way to turn off the coke machine. When you run the program from within Eclipse, you can stop it by pressing the red square.


Here is an example of the use of the program. Program output is blue, user input is brown.

  Insert coin: 25
  Amount entered: 25
  Insert coin: 25
  Amount entered: 50
  Insert coin: 10
  Amount entered: 60
  Insert coin: 15
  Rejecting 15 cent coin
  Amount entered: 60
  Insert coin: 25
  Amount entered: 85
  Insert coin: 10
  Amount entered: 95
  Insert coin: 25
  Amount entered: 120
  Please make selection:
  1 - Coke
  2 - Coke Zero
  3 - Caffeine Free Diet Coke
  Your choice: 2
  Dispensing Coke Zero
  Returning dime
  Returning dime

  Insert coin: 

To avoid problems with static, use the following program organization:

package cokeMachine;

 * Coke machine simulation.
 * @author Your name goes here
 * @version Jan 23, 2009
public class CokeMachine {
    int amountEntered = 0;
    public static void main(String[] args) {
        new CokeMachine().run();

    private void run() {
        // Your code goes here

Structure of the assignment:

The above are requirements. You may have additional classes and methods as needed.

Due date:

Before midnight, January 29, 2009, via Blackboard.