Computer Science 1511
Computer Science I

Programming Assignment 2
Input and Formatted Output (35 points)
Due Thursday, September 30, 1998

Introduction

In this lab assignment you will write your own C program, following the strategy presented in class. It will give you practice 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

Jenny's Book Store supplies textbooks to three universities, UMD, UW-Madison, and the Wetlands Institute. The four textbooks Jenny's store supplies are titled Anatomy, Biology, Computer Science, and Databases. Jenny's needs you to create a program that prints out how much they need to charge each University. Your program should prompt for how many of each textbook was sold to each university and then print out a chart showing total sales and total costs as shown below.

The person using the program will enter how many of each of the four types of books each of the universities has ordered. You will then need to calculate how many of each type of book has been ordered (right column), the total number of books ordered by each university (row labelled "Total"), the cost of the books (next row), the tax on the books (next row), and the total cost (final row).

The book ANATOMY costs $70, BIOLOGY $40, COMPUTER SCIENCE $45, and DATABASES $55. The tax rates are 8.5% for UMD, 6% for UW-Madison, and 7% for the Wetlands Institute.

NOTE: your program should produce EXACTLY the following output.

Sample Run of the Program

For UMD:
  How many copies of ANATOMY? 165
                     BIOLOGY? 230
            COMPUTER SCIENCE? 190
                   DATABASES? 25

For UW-Madison:
  How many copies of ANATOMY? 250
                     BIOLOGY? 450
            COMPUTER SCIENCE? 300
                   DATABASES? 55

For Wetlands Institute:
  How many copies of ANATOMY? 25
                     BIOLOGY? 220
            COMPUTER SCIENCE? 0
                   DATABASES? 0


*****************************************************************

Jenny's Book Store

-----------------------------------------------------------------
| Book      |        UMD | UW-Madison | Wetlands I |      Total |
-----------------------------------------------------------------
| ANATOMY   |        165 |        250 |         25 |        440 |
| BIOLOGY   |        230 |        450 |        220 |        900 |
| COMP SCI  |        190 |        300 |          0 |        490 |
| DATABASE  |         25 |         55 |          0 |         80 |
-----------------------------------------------------------------
| Total     |        610 |       1055 |        245 |       1910 |
-----------------------------------------------------------------
| Book Cost | $ 30675.00 | $ 52025.00 | $ 10550.00 | $ 93250.00 |
| Tax       | $  2607.38 | $  3121.50 | $   738.50 | $  6467.38 |
-----------------------------------------------------------------
| Tot Cost  | $ 33282.38 | $ 55146.50 | $ 11288.50 | $ 99717.38 |
-----------------------------------------------------------------

*****************************************************************

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.