CIS071 Lab02 - Value of an English Coin Collection DUE: (Noon, Wed, Feb 01, 2006)
Modify the documentation and code of the U.S. Coins program
(uscoins.c) to use English Coins (name this program engcoins.c)
The coins in this collection and their values in pence are:
crown = 60 pence; shilling = 12 pence;
pence = 1 pence
Prompt the user for the number of coins of each kind. Then, calculate and
display the total value in pounds and pence (1 pound = 240 pence).
1. Make a new directory (e.g. mkdir Lab02)
and include it in the default path (e.g. cd
Lab02).
2. Use the browser to display and “save as” in this directory, the
program uscoins.c from the website: uscoins.c
3. Use the command: gcc
uscoins.c -o uscoins to
compile the program and generate an executable file uscoins.
4. Test this program to be sure that it works correctly
5. Use pico (or another editor) to
modify the program so that it works with English coins and save it as engcoins.c.
Be sure to include documentation at the beginning of the
program, specifically:
Requirements: What is
the program supposed to do?
Method: How will
the program do it?
Test Plan: What are the
tests to demonstrate that the program works
6. Recompile, test and correct the revised program as
often as necessary until it works correctly.
7. Retest (according to your Test Plan – see below), using the “capture”
tool to save to a file the evidence that your program works correctly.
Testing is very important component of program design. You want to make sure that your program runs correctly and to be aware of its limitations. Your test plan should start with simple examples and you will have to manually check if its output is correct. Then, you should try to “cheat” you program to expose its limitations. For example, try entering more or less than 3 letters when asked for the 3 initials. What happens when you enter float number (e.g. 2.34) as a coin number? What happens if you input character or a word?
NOTE: Professional programs should not allow “cheating.” For example, one could prompt a user to enter information in the correct format, and refuse to continue or terminate the program if the instructions are not followed correctly.
8. (Optional) Do you have some explanation for behavior of
your program when you try to “cheat” it? (Please, paste your discussion in the
main body of your e-mail submission.)
9. Use the “Pine” email facility to submit this
program to the correct lab account.
Use a Subject of Lab02 and attach the
files engcoins.c and engcoins.dat
Do NOT attach any uscoins
files or the executable file engcoins!
Example of documentation at the beginning of the program
/* Program Title: uscoins
* Author, Date: John Doe 1/22/06
*
* Requirements: Compute the value of a coin
collection consisting of
* pennies, nickels,
dimes, quarters. Query the user for quantities
* of each coin.
Display the total value of the collection in
* dollars and cents.
*
* Method: Query the user for the count of each
coin.
* total_cents =
25*number quarters + 10*number dimes + 5*number nickels + number pennies
* dollars =
total_cents/100 (truncated integer division)
* cents =
total_cents%100 (modulo)
*
* Test Plan: Test with 0 of all coins; then
just pennies, just nickels,
* just dimes, just
quarters; then total < 1 dollar, total > 1 dollar
* (change 0 and change not = 0), enter jiberish values
*/