Indiana University of Pennsylvania
Computer Science Department
CO 110 Main Session 84
Programming Assignment #2
For this project you are to write a program to perform the
functions of a cash register and a change maker at your terminal.
Assume that you are running a small market like 7-11, Sheetz, or
MiniMart, where customers generally make small purchases. Your
program must handle three customers. (You should make the number
of customers a parameter so that it can be changed easily.) The
total of purchases made by each customer is guaranteed to be less
than $5.00; and customers are expected to pay by offering no more
than $5.00 to pay for their purchases.
Your program should read in a series of costs for items with
an indication of whether or not each item is taxed. The program
must compute the total costs for the taxed and non-taxed items.
Following is a set of purchases for one customer; the data uses a
zero cost as a sentinel to end each customer's data.
Data Description
0.30 'N' Cost is $0.30, not taxed
0.63 'T' Cost is $0.63, taxed
0.22 'N' Cost is $0.22, not taxed
1.54 'T' Cost is $1.54, taxed
0.00 'N' Sentinel value
The program must calculate the overall cost (including tax, which
is 6% of the taxable total) and print it in the following form:
TOTAL COST IS 2.820200
The program should then accept the amount tendered by the
customer to pay for the purchases (in this case $5.00) and
calculate the change. The program should print out the amount of
change and form the change will take, as follows.
YOUR CHANGE IS 2.179800
2 ONES 0 QUARTERS 1 DIMES 1 NICKELS 3 PENNIES
To determine how the change breaks down into the coins, your
program should perform the following steps.
1. Get the number of ONES by using an integer variable.
2. Get the rounded integer number of cents from the
fraction of a dollar that remains.
3. Get the number of QUARTERS, DIMES, etc. by dividing
the number of remaining cents by 25, 10, etc.
For each value to be input, your program must display a
prompt to tell the person at the terminal what to do next. The
prompt for each item is 'SALE:'. The prompt for the amount the
customer offers to pay for the items is 'TENDERED:'. Before your
program begins to handle the purchases for any customer, it
should display the message 'NEXT CUSTOMER:'. After processing
the purchases of the three customers and printing out their
change, your program must produce a change summary to indicate
the total number of each type of coin given in change. The
summary's form is as follows.
CHANGE SUMMARY
QUARTERS DIMES NICKELS PENNIES
4 3 2 7
The data you should use with your program is listed below.
0.30 'N'
0.63 'T'
0.22 'N'
1.54 'T'
0.00 'N'
5.00
0.33 'T'
1.19 'T'
0.89 'T'
0.00 'N'
3.00
2.84 'N'
1.32 'N'
0.00 'N'
5.00
Your program must make sure that the amount tendered is
valid; that is, the amount must be less than or equal to $5.00
and greater than or equal to the total cost. To verify that your
program does this, you should deliberately make at least one
mistake in entering the amount tendered. When your program
detects an invalid amount, it should print the message,
INVALID AMOUNT, TRY AGAIN
prompt for the amount again, and read in the new amount.
You must hand in a flowchart with your program listing.
This flowchart should be on 8 1/2 x 11 paper and should be a
detailed representation of your program. Use connectors to show
how the different parts of the flowchart and different pages fit
together. Place the flowchart page(s) inside the printout or
attach the page(s) with a paper clip.
IMPORTANT NOTES
1. The sentinel data lines must include a character to indicate
the tax status even though it is not used in the program.
2. The tax status indicator is one character (an N or a T) and
must be enclosed in quotes.
3. You must use a DO loop in which all processing for a single
customer is handled.
4. You must hand in a single unbroken piece of paper showing
your program listing and the running of the program. The program
listing must be produced by the FORTRAN compiler, not by EDIT.
5. The data and time must appear on the program listing. One
way to make sure this happens is to give the IBEX command DISPLAY
after running the program.
6. Required internal and external documentation for this program
is the same as for program #1.
7. You may not use arrays, formatted READ, or formatted PRINT
for this program. Use of GO TOs should be limited to
implementing a loop.