$\textstyle \parbox{1.5in}{CS1320}$ $\textstyle \parbox{3in}{\Large CS1321 Homework~1}$ $\textstyle \parbox{1.5in}{2000 Jan~11}$


Due Thursday, 2000 Jan 20, at the beginning of class.



Reading

Read chapter 1 of the textbook.

Programming Tips

Software Design Tip

Unlike writing essays, it is frequently easier to build programs by iteratively adding features. If you test after each adding each feature, any mistakes are likely to be in the newly added code.

Xemacs Tip

To edit a file called ``foo.cc'' using the text editor Xemacs, type xemacs foo.cc & in any shell. Omitting the filename just starts Xemacs. Omitting the ampersand (&) will prevent the shell from being used until Xemacs finishes; this may be the right behavior when using Xemacs via telnet.

Compilation Tip

Use the g++ -Wall -pedantic compiler options to produce warning messages. This may help find programming mistakes more easily than the default of producing just using syntax errors.

Use the g++ -o output-file-name compiler options to name the resulting executable ``output-file-name.''

For example, one could use

g++ -Wall -pedantic foo.cc -o foo
to compile a C++ file named ``foo.cc'' and create an executable called ``foo,'' rather than ``a.out.''

Submission Rules

Please submit your homework via email to cs1321-1@cs.trinity.edu or to cs1321-2@cs.trinity.edu, according to your section. Please read the instructions. For this homework, please email only your source code file, not any test files, e.g., a file of sales tax rates. There is no need for a Makefile.

Problems

Write a program to compute the correct state sales tax, given a list of item prices. For example, a retailer selling two items each costing $3.45 and one item costing $123.45 could compute the sales tax by typing

salesTax salesTaxRates TX 3.45 3.45 123.45

into any shell.

salesTax is the name of the executable program.

salesTaxRates is the name of a file with each line containing a two-letter state abbreviation, e.g., TX and CA, and the state sales tax rate written as a percentage, e.g., 6.25 for Texas and 7.25 for California. Sales tax rates are stored in a file because they continually change.

TX indicates the state for which the sales tax should be computed.

3.45 3.45 123.45 indicates the item prices, written as decimal numbers with two digits after the decimal point.

The program should print 8.15, which is the sales tax due. That is,

(3.45 + 3.45 + 123.45)*6.25% = 8.146875,

which is then rounded to the closest penny.

Details:




2000-01-18