Project 3
MyJava Coffee Outlet

Due: Mon., March 26, 8 AM
Submit Project: Proj3
Required Files: Proj3.java
Grading Header: header.txt
Test Data: testa.dat testb.dat testc.dat
Model Output: out.dat

Having completed projects that use simple arithmetic expressions, we will be continuing to build on that knowledge with this project. We will also include a test of your knowledge of the if and if/else statements. You will also be required to do some basic problem solving and organization of conditional statements, as well as basic keyboard input and output.


Program Description

MyJava Coffee Outlet runs a catalog business. It sells only one type of coffee beans, harvested exclusively in the remote area of Irian Jaya. The company sells the coffee in 2-lb bags only, and the price of a single 2-lb bag is $5.50. When a customer places an order, the company ships the order in boxes. The boxes come in three sizes: the large box holds 20 bags of 2 lb, the medium 10 bags, and the small 5 bags. The cost of a large box if $1.80; a medium box, $1.00; and a small box, $0.60. The order is shipped using the least number of boxes. For example, the order of 22 bags will be shipped in two boxes, one large and one small. In addition MyJava Coffee Outlet has decided to give discounts to volume buyers. The discount is based on the following table:

Order VolumeDiscount
>= 25 bags5% of total price
>= 50 bags10% of total price
>= 100 bags15% of total price
>= 150 bags20% of total price
>= 200 bags25% of total price
>= 300 bags30% of total price

Develop an application that computes the total cost of an order, including cost of the beans, the appropriate discount, and the cost of the boxes. Display the output in the format specified in the Output Specifications section.


Project Specifications

  1. Your program must be in a file named Proj3.java.
  2. You must import any libraries you feel you need.
  3. All your code should appear in a single class. The entire project can be in a single method: main. However if you feel that breaking the problem up into methods which are called upon at the appropriate times to get things done, that is fine as well. Make sure that if you do this, that local variables are declared in the appropriate places and that parameters are passed correctly.
  4. There are many constants and variables in the program. Declare the constants first and then the variables. Put them all together at the top of the program. Do not scatter them around the body of the program.
  5. Declare a Scanner object and any other objects you feel you'll need.
  6. Prompt the user to enter the number of bags of coffee beans being purchased. Read the value entered on the keyboard and echo-print it back to the screen exactly as it were entered.
  7. Next, write a blank line to separate screen input from screen output.
  8. If 0 bags are entered, print an appropriate message and exit the program.
  9. Calculate the total gross cost and print it followed by a blank line.
  10. Calculate the appropriate discount, if any and print it. If there is no discount, print nothing here.
  11. Calculate the appropriate boxes and their costs. Do not print a box size if it is not used. Assume that the only size box that can have a partial shipment is a small box. All others must be full to be used.
  12. Print the total charge followed by a blank line.
  13. Notice the colons are lined up in the outputs as well as the hyphens in the box part of the output.


Output Specifications

The output from a single run of your program must match the following. Your output should look as much like the following as possible.

Please enter the number of bags of coffee purchased: 53
53

Number of Bags Ordered: 53 - $291.50

              Discount:
                        10% - $29.15

            Boxes Used:
                        2 Large  - $3.60
                        1 Medium - $1.00
                        1 Small  - $0.60

  Your total charge is: $267.55

Another:
Please enter the number of bags of coffee purchased: 21
21

Number of Bags Ordered: 21 - $115.50

            Boxes Used:
                        1 Large  - $1.80
                        1 Small  - $0.60

  Your total charge is: $117.90


Testing

I have given you 3 possible test cases above which you can run by hand. The output from those three sets of data is in out.dat. Run as many test cases as you think necessary to make sure your program works under all normal input conditions.


Specifications for Documentation and Format

Normally you will be expected to determine what documentation and formatting will be necessary for your project on your own, with the help of the Style Guide in your Lab manual. Fully correct documentation must follow the javadoc conventions and include:


Submission Submit your program file electronically: In Eclipse, right click on the project and import the files from /home/f85/debbie/cs141/Proj3. Right click on the file submit.xml and select Run -> 1 Ant Build; Messages will appear in the Console window. Be sure to determine whether you got the Build successful message to ensure that your electronic file submission for this lab was successful.

Honor Code. The honor code applies to all programming done in this course. Reread the CS Department's document: Programming Assignments and the Honor Code.

Start now .. your mileage may vary


Debbie Noonan, debbie@cs.wm.edu
Feb. 23, 2007