CSE 142 Homework #2

The two parts are relatively independent.  However, it would be best to do Part A first, as a warm for Part B.  Completing the exercises will give you experience writing the functions you need for the programming assignment.


Exercises

The exercises are to complete the functions given in the program below. The comments above each function specifies what it should do. Most of the functions are given as "stubs", that is, with a header (prototype) and a brain-dead return statement.  For some functions, you may also have to write the header portion.  You are to complete the function  in each case. You are *not* to modify the main program. The main program provides a set of test calls to the functions to test if your implementation is correct.

A sample solution is not provided, since when you compile the starting code, the test harness will print out the results of your functions. In order to get the program to compile, you will need to write a version of the function orderCheck which is syntactically correct.


Programming Assignment: Ordering Muggle Goods


Overview

The wizards were impressed with your earlier work and have promoted you to the Muggle goods procurement department.  You will use what you learned on your last project, as well as your new knowledge of conditionals and functions, to design a program that assists in ordering supplies from the Muggle world.  Your program will generate order reports for items purchased from a several suppliers.


Key Concepts

In this homework, keep an eye out for


Specifications

This is a simple program to create order forms based on a request for 6 items from 3 different suppliers. You can order Wormwood, Nettles, Snake fangs, Snails, Porcupine quills, and Potion vials.  These items have the following costs:

Item No. Item Cost
1 1 ounce Wormwood $6.50
2 1 ounce Nettles $3.99
3 1 Snake fang $24.99
4 1 Snail $13.25
5 1 Porcupine quill $2.99
6 1 Potion vial $10.50

Your program should request the following as input:

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

Supplier No. Supplier Supplies
1 California Dreams Wormwood, Nettles
2 Parts R Us Snake fangs, Snails
3 MalWart Potion vials, Porcupine quills

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, 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. It returns the cost of the order. It will make use of the following functions:
  2. printSupplierName -- This function takes a supplier number and prints the name of the supplier corresponding to that supplier number.
  3. printItemName -- This function takes an item number 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.

Getting Started

We've provided a workspace and starter code to help you on your way, including function definitions.

You will also want to download and run the sample PC executable and see some sample runs of the program.


A few bits of advice


Last updated: 01/30/2001 12:45 AM