CS 0401 – Project 1: The Java Shoppe
Due: Sunday, May 31, 2015 by Midnight

If you program in Java for any amount of time, the coffee jokes are inevitable. So for your first project, we will write a small point-of-sale program for a fictional coffee shop that offers a variety of products.

The Menu

The Java Shoppe offers the following items for the specified prices:

Brewed Coffee

 

                Small

$1.50

                Medium

$1.75

                Mondo

$2.50

Chocolate Chip Muffin

$1.75

Pot of Tea

$2.00

Hot chocolate

$2.50

Water

$2.00

Organic Water

$4.00

 

It also offers the following specials:

·         Buy a Mondo coffee, get a muffin for $1.00

·         Buy organic water, get a free chemistry textbook

The program

Present the user with a prompt for what item the customer is purchasing:

The Java Shoppe Menu:

     1.) Brewed Coffee

     2.) Chocolate Chip Muffin

     3.) Pot of Tea

     4.) Hot chocolate

     5.) Water

     6.) Organic water

     7.) Check out/Print receipt

Which item is being purchased?

 

If the choice is brewed coffee, present the prompt:

Coffee sizes:

     1.) Small

     2.) Medium

     3.) Mondo

What size?

 

After the item to purchase is fully specified, prompt for quantity:

How many?

Repeat the menu until the user checks out by choosing 7.

When they check out, calculate the total bill for the customer. For instance, if the customer bought 1 Mondo Coffee, 1 Chocolate chip muffin, and 1 organic water, display:

1	Mondo Coffee			$2.50
1	Chocolate Chip Muffin		$1.75
1	Organic Water			$4.00
----------------------------------------------------
	Mondo Muffin Discount		$-0.75
	Free chemistry textbook		$0.00
----------------------------------------------------
	Subtotal:			$7.50
	5% Java Tax:			$0.38
----------------------------------------------------
	Total:				$7.81

 

Prompt the user for the amount of money the customer paid, and if necessary, display the amount of change to return.

Customer paid? $10.00

Their change is $2.39

 

And then exit.

Requirements and Hints

 

·         Name your class (and your file) JavaShoppe

·         Use the Scanner input code from Lab 2 to read in your input.

·         Reject invalid choices at any menu and re-display the prompt. (You only have to forbid invalid numbers, not the user typing something that is not a number.)

·         To format a float called “price” in the money format (leading $, two decimal places, etc.) use the code:

System.out.printf("$%,.2f", price);

·         You can replace “price” with whatever variable you want to display

·         Don’t try to read in money with the $. Just print it out and then the user can type 10.00 Use the nextDouble() method instead of nextInt() on your scanner to read the value.

·         You must document your code using comments and good programming style as we have defined in class. Pick good variable names, use proper indentation, etc.

·         You should give a discount for each Mondo/Muffin bought.

·         You should only give a single free textbook regardless of how many organic waters are purchased.

Submission

Create a JavaShoppe.zip file that contains your JavaShoppe.java file. Upload it to the submission website as we have been doing with labs. Make sure to do this prior to the deadline. No late work is accepted.

If, prior to the deadline, you realize that you need to submit a different version of your code, name it JavaShoppe-2.zip. (You can add new numbers as necessary, but try not to submit many times.)

We will grade the last submission that was prior to the deadline.