Computer Science 1621
Computer Science I

Programming Assignment 2
Input and Formatted Output (30 points)
Due Monday, September 28, 1998

Introduction

In this lab assignment you will write your own C program, following the strategy presented in class. It will give you practice producing reading values, producing formatted output, using program constants, and in simple arithmetic. First, determine the inputs and outputs of the problem, then write an algorithm for solving it. Next, refine the steps of the algorithm until the algorithm is sufficiently detailed that it is easily converted into C statements. Finally, write the program. Once your program is written, you will enter, compile and test it just as you did for Program 1.

The Problem

Kathleen is the sales rep for a company that produces three products: centrifuges, microscopes, and kilns. In one of her sales areas she supplies three New Jersey universities, Princeton, Rutgers, and Seton Hall. Since Kathleen is busy, she has asked you, her assistant, to create a program that produces a simple chart of her sales to show to her supervisor. Your program should prompt for how many of each item was sold to each university and then print out a chart showing total sales and total costs as shown below.

The center rows and columns of the table show the amount each university ordered (as entered by the user). The right column shows the total number of each item ordered by the universities. The bottom row shows how much each university should be charged for the items they purchased. The bottom right entry shows the total sales to all three universities. Each Centrifuge costs $3500, each microscope costs $235, and each kiln costs $9000.

NOTE: your program should produce EXACTLY the following output.

Sample Run of the Program

For Princeton University:
  How many Centrifuges? 3
           Microscopes? 25
           Kilns? 1

For Rutgers University:
  How many Centrifuges? 0
           Microscopes? 50
           Kilns? 3

For Seton Hall University:
  How many Centrifuges? 2
           Microscopes? 75
           Kilns? 1



Kathleen's Sales

------------------------------------------------------------------
| Item       |  Princeton |    Rutgers | Seton Hall |      Total |
------------------------------------------------------------------
| Centrifuge |          3 |          0 |          2 |          5 |
| Microscope |         25 |         50 |         75 |        150 |
| Kiln       |          1 |          3 |          1 |          5 |
------------------------------------------------------------------
| Total      | $ 25375.00 | $ 38750.00 | $ 33625.00 | $ 97750.00 |
------------------------------------------------------------------

What to Hand In

Consult the Programming Assignment Guidelines for information on what to put in the report to go with this program. For this program you do not need to include the implementation section since this program will not have subprograms. Make sure that your test output shows that your program produces output exactly like that given above. You should also include other samples of your program running (on different data values to demonstrate that it works). You may also want to include samples of data that will not work for your program.