CSE 142 Homework 2
Due Sunday, July 9th, 10:00 PM
Paper turn in Monday, July 10th, 5:00 PM
Pleased with your performance on earlier projects, your boss has decided to keep you as head
developer. During your late night hacking sessions, your group often
became thirsty, hungry or sleepy, and ordered the necessary food-type
items to keep it going. Tired of generating order forms by hand,
you've suggested to your boss that you should develop a program to
help quickly order the supplies needed to help get programmers through the
night. He has agreed, and development is underway.
Overview
As the head software engineer at HHGG, you will write a program
to help order the supplies needed to keep your team strong and alert.
You will use what you learned on your last project,
as well as your new knowledge of conditionals and functions.
Read the entire assignment carefully and thoroughly. Pay close
attention to the specifications below, as that details what your
program must do.
Quick Overview
Specifications
This is a simple program to create order forms based on a request
for a few (6) greatly needed items from 3 different suppliers. You can order Coke, Beer,
Sugar Stix, Caffeine, Burgers, and cheese Pizza. These items have the following costs:
Item No. | Item | Cost |
1 | 1 can Coke | $0.25 |
2 | 1 bottle Beer | $0.75 |
3 | 1 Sugar Stix | $0.10 |
4 | 1 gram Caffeine* | $5.00 |
5 | 1 Burger | $0.49 |
6 | 1 Pizza | $5.99 |
As this program is fairly complex, you may want to first look at
the Sample Executions.
Also, you
will find the starter code very helpful
for this assignment.
Your program should request the following as input:
- The number of cans of Coke desired
- The number of bottles of Beer desired
- The number of Sugar Stix desired
- The number of grams of Caffeine desired
- The number of Burgers desired
- The number of Pizzas desired
Based on the values input above, it will generate order
requests to the suppliers:
Supplier No | Supplier | Supplies |
1 | Ernie's Drink Co. | Coke, Beer |
2 | Pick-Me-UP Inc. | Sugar Stix, Caffeine |
3 | Yummy Food Distributors | Burgers, Pizza |
Your program should generate the following output:
- If at least one (1) item is ordered from a supplier, then an order request
should be generated for that supplier.
- Only one (1) order request per supplier
- No order request if neither of the suppliers' items were desired
- An order request should contain the following:
- The name of the supplier of the item(s)
- The quantity, name, and cost of purchasing that many of the first item (if the quantity is greater than zero)
- The quantity, name, and cost of purchasing that many of the second item (if the quantity is greater than zero)
- The sub-total of this order
- Lastly, you should print the total cost of all orders
You will implement a few functions to help you generate the above
order requests:
- MakeOrder -- This function takes a supplier number (listed above), an item number, the quantity for that item, and a second item number and quantity. It will produce the order request for the intended supplier and items (as specified above). It returns the cost of the order. It will make use of the following functions:
- printSupplierName -- This function takes a supplier number (see above) and prints the name of the supplier corresponding to that supplier number.
- printItemName -- This function takes an item number (see above) and prints out the name of the item corresponding to that item number
- PerItemCost -- This function takes an item number and returns the cost of a single unit of that item (see above).
See the following page for sample executions.
Suggestions and Hints
You should make good use of constants, conditionals, comments, and the switch statement. Don't forget the return statement in functions that return values.
Remember, it is better to have a program that compiles and runs without
complete functionality, than a program that doesn't compile or run. Consider
writing the program in smaller pieces, and testing those. For example, write the input, test, a function, test, etc.
Sample Executable
Download and run the sample PC executable hw2.exe.
See some sample runs of the program.
Getting Started
We've provided a workspace and starter code
to help you on your way, including function definitions.
Download the MSVC 6.0 self-extracting archive.
MSVC 5.0 here
If
you are not using Windows, or this doesn't work for you, you can download
the starter code by itself.
Submitting Your Work
Use the turnin page.
You may turn in the program as many times as you wish. Only the
last version is graded, and only the receipt from this last version
should be handed in.
* Note: For perspective, 1 can of Coke has 45.6 milligrams of caffeine.
A cup of coffee has about 100 milligrams. See here for more information.