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.ItemCost
11 can Coke$0.25
21 bottle Beer$0.75
31 Sugar Stix$0.10
41 gram Caffeine*$5.00
51 Burger$0.49
61 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:

Based on the values input above, it will generate order requests to the suppliers:

Supplier NoSupplierSupplies
1Ernie's Drink Co.Coke, Beer
2Pick-Me-UP Inc.Sugar Stix, Caffeine
3Yummy Food DistributorsBurgers, Pizza

Your program should generate the following output:

You will implement a few functions to help you generate the above order requests:
  1. 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:
  2. printSupplierName -- This function takes a supplier number (see above) and prints the name of the supplier corresponding to that supplier number.
  3. printItemName -- This function takes an item number (see above) and prints out the name of the item corresponding to that item number
  4. 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.