Moving on with our new found skills, it's time to write a program
incorporating the looping structures we've learned. Of course, we
will build on old information too, incorporating into our program
other structures like the
if and
switch statements as well as method creation and calling. There
is only one file for this project, therefore the extra methods that you create must all be
static methods. We will also define a few static variables. Arrays can NOT
be used for this project.
With this program you are going to keep track of the inventory of the Clipper Manufacturing Company (CMC). CMC manufactures five products:
CMC's warehouse has room for only 50 of each item. There is never a negative number of any of the products. CMC would like you to write a program to keep track of the number of each product in the warehouse. Your program should be able to display the amounts in a bar chart along with the number in the inventory for each product.
Write a program that implements this inventory program.
Proj4.java.
main, declare a Scanner object. There should
only be one. Pass this as a parameter to the appropriate methods as needed.
*** CMC Inventory System *** A) Add to an item's inventory. R) Remove from an item's inventory. G) Graph the current items stored in the warehouse. Q) Quit
1) Bicycle 2) Unicycle 3) Moped 4) Skateboard 5) Skates
A program run might look like the following (don't forget to echo-print all input):
*** CMC Inventory System *** A) Add to an item's inventory. R) Remove from an item's inventory. G) Graph current items stored in warehouse. Q) Quit. Enter choice: a a 1) Bicycle 2) Unicycle 3) Moped 4) Skateboard 5) Skates Choose an item number: 1 1 Enter quantity to add to inventory: 20 20 *** CMC Inventory System *** A) Add to an item's inventory. R) Remove from an item's inventory. G) Graph current items stored in warehouse. Q) Quit. Enter choice: a a 1) Bicycle 2) Unicycle 3) Moped 4) Skateboard 5) Skates Choose an item number: 3 3 Enter quantity to add to inventory: 10 10 *** CMC Inventory System *** A) Add to an item's inventory. R) Remove from an item's inventory. G) Graph current items stored in warehouse. Q) Quit. Enter choice: a a 1) Bicycle 2) Unicycle 3) Moped 4) Skateboard 5) Skates Choose an item number: 1 1 Enter quantity to add to inventory: 40 40 *** ERROR: maximum items exceeded *** *** CMC Inventory System *** A) Add to an item's inventory. R) Remove from an item's inventory. G) Graph current items stored in warehouse. Q) Quit. Enter choice: r r 1) Bicycle 2) Unicycle 3) Moped 4) Skateboard 5) Skates Choose an item number: 3 3 Enter quantity to remove from inventory: 15 15 *** ERROR: Cannot remove that many items *** *** CMC Inventory System *** A) Add to an item's inventory. R) Remove from an item's inventory. G) Graph current items stored in warehouse. Q) Quit. Enter choice: G G Item Number Chart Bicycle 20 ******************** Unicycle 0 Moped 10 ********** Skateboard 0 Skates 0 *** CMC Inventory System *** A) Add to an item's inventory. R) Remove from an item's inventory. G) Graph current items stored in warehouse. Q) Quit. Enter choice: A A 1) Bicycle 2) Unicycle 3) Moped 4) Skateboard 5) skates Choose an item number: 6 6 Illegal item number entered. Please try again. 1) Bicycle 2) Unicycle 3) Moped 4) Skateboard 5) skates Choose an item number: 5 5 Enter quantity to add to inventory: 10 10 *** CMC Inventory System *** A) Add to an item's inventory. R) Remove from an item's inventory. G) Graph current items stored in warehouse. Q) Quit. Enter choice: P An illegal option has been entered. Please try again. *** CMC Inventory System *** A) Add to an item's inventory. R) Remove from an item's inventory. G) Graph current items stored in warehouse. Q) Quit. Enter choice: Q Q Thank you for using the Inventory Control System.
With the help
of the Style Guide in your Lab manual, fully document your code
following the javadoc conventions for prologues and include:
} // main
Information needed for testing this program are linked from the top of the page. Test your program thoroughly with the data and sample output given before submitting.
Submit your program file electronically: In Eclipse, right click on the project and import the files from /home/f85/debbie/cs141/Proj4. 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.