I have been working on this assignment which is supposed to use an old code. I am having a hard time visualizing what I'm supposed to do.
General Information
This program manipulates data about counties and their sales tax rates in the state of Tennessee.
Detailed Information
The state of Tennessee has a sales tax rate of 7%. Counties and even cities add their own tax rates to this. For example, Blount county has a sales tax rate of 2.25% but Alcoa (in Blount county) has a sales tax rate of 2.75%.
This program inputs data about Tennessee counties and their sales tax rates from an input file whose format is shown below. County names may have any spaces in them and the case of their letters may be incorrect. A county name will always be on a line by itself and will always be followed by its sale tax rate. There will be no extraneous characters in the file.
county_name
tax_rate
For example:
knox
2.25
vAN bUREN
2.75
davidson
2.25
grainger
2.75
loudon
2.5
anderson
2.75
The name of the input file is obtained from the user. The data is read into an array of structures then sorted by county name and printed to the screen in table formatted like the one shown in Sample Execution 3. There will be at most 10 counties in the input file. The longest county name is 10 characters. The biggest tax rate is less than 100%. There are actually 95 counties in Tennessee so write your program so it would be easy to change to work for 95 counties (i.e., use constants).
Get the input file name from the user.
If the input file doesn’t exist, print the error message: Input file ____ does not exist (where ___ is the name of the input file).
If the input file exists but is empty, print the error message: Input file ___ is empty. (where ___ is the name of the input file).
If the input file has fewer than 10 entries, partially fill your arrays and process these. If the input file has more than 10 entries, just process the first 10. (This is not an error. You will print a table with the first 10 entries in the file)
YOU MUST WRITE AND USE YOUR OWN FUNCTIONS. IF YOU PUT ALL OF YOUR CODE IN main YOU WILL NOT RECEIVE ANY CREDIT ON THIS LAB. You must have, at least, separate functions to read, sort and print.
You MUST use an array of structures.
You MUST use a C-strings in the structure the county name.
Use constants where appropriate.
Sample Execution 1:
Welcome to the Tennessee Sales Tax Report!
Enter input file name: data.dat
Input file data.dat does not exist.
Sample Execution 2:
Welcome to the Tennessee Sales Tax Report!
Enter input file name: emptyFile
Input file emptyFile is empty.
Sample Execution 3: (country names left aligned, sales tax rates right aligned with exactly 2 digits to the right of the decimal)
Welcome to the Tennessee Sales Tax Report!
Enter input file name: TNdata.dat
County Sales Tax Rate
--------------------------
Anderson 2.75%
Davidson 2.25%
Knox 2.25%
Loudon 2.50%
Van Buren 2.75%
Here is my old code. If you can help me asap, much would be appreciated.
To me all it looks like is to check for upper and lower case and sort them by county names as opposed to tax rate which my old code was sorting that way.