Due Thursday, 2000 Jan 20, at the beginning of class.
Read chapter 1 of the textbook.
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.
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.
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
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.
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
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,
Details:
The example given above has six command-line arguments, separated by whitespace. Just as for arrays, they are numbered starting with zero. For example, argv[2] is TX, and argv[5] is 123.45.
Here are the three rules for using command-line arguments: