$34.99
Assignment Overview
This assignment focuses on C shell programming in a Linux environment. You will design and implement a set of C shell scripts which are used to produce reports about census data.
Assignment Deliverables
The deliverables for this assignment are the following files:
proj02.script1 -- the C shell script which produces Report #1 proj02.script2 -- the C shell script which produces Report #2 proj02.script3 -- the C shell script which produces Report #3 proj02.script4 -- the C shell script which produces Report #4
Assignment Specifications
The following files are available on the CSE Linux system:
/user/cse325/Projects/project02.data
/user/cse325/Projects/project02.headers
The first file contains the list of cities and townships (census units) within each county in Michigan. For each census unit, the file contains the total population recorded during the 2010 United States Census. The first five lines of that file are shown below:
Acme township | Grand Traverse | 4375
East Lansing city | Clinton | 1969
Bois Blanc township | Mackinac | 95
East Lansing city | Ingham | 46610
Newark township | Gratiot | 1093
The second file contains column headers which are formatted for use with this data:
Census Unit | County | Population
-------------------------------------+----------------+-----------
You will design and implement four C shell scripts which are capable of producing the reports described below.
1. The C shell script "proj02.script1" will produce a report about the census units within a specified county. The second command-line token is an identifier for the specified county (for example, "Ingham" or "Grand Traverse").
The report will include an appropriate title, the column headers described above, and all of the census units in a specified county. The census units will be sorted by population (from lowest to highest); if more than one census unit has the same population, the report will list those places alphabetically.
2. The C shell script "proj02.script2" will produce a series of individual reports about the census units in a list of specified counties. The second and each subsequent command-line token is an identifier for a specified county.
Each report will include an appropriate title, the column headers described above, and all of the census units in a specified county. The census units will be sorted by population (from lowest to highest); if more than one census unit has the same population, the report will list those places alphabetically. Individual reports will be separated by exactly two blank lines.
3. The C shell script "proj02.script3" will produce a report about the N census units with the largest population.
The report will include an appropriate title, the column headers described above, and the population for the top N census units (where N is a positive integer) from a subset of the places in Michigan, sorted by population (from highest to lowest). If more than one census unit has the same population, the report will list those places alphabetically.
Your C shell script will accept two arguments: a positive integer number that specifies the value of N, and a character string which specifies the subset of census units which should be included in the report. This character string will be "A" (meaning that all places should be included), "C" (meaning that only places which are cities should be included), or "T" (meaning that only places which are townships should be included).
4. The C shell script "proj02.script4" will produce a report about the N census units with the largest population.
The report will be identical to Report #3 described above. However, your C shell script which produces the report will include error checking.
If the user supplies an invalid number of arguments, your C shell script will display an appropriate error message.
If the user supplies an invalid value as the second token (something other than an integer value which is greater than zero), your C shell script will display an appropriate error message.
If the user supplies an invalid character string as the third token (something other than "C", "T" or "A"), your C shell script will display an appropriate error message.
Assignment Notes
1. The first line of each of your C shell scripts must be the line shown below (where the '#' character is in the first column):
#!/bin/tcsh -f
3. The following are examples of valid commands which use the C shell scripts:
proj02.script1 Wayne
proj02.script2 "Grand Traverse" Gratiot Wexford proj02.script3 25 A proj02.script4 10 C
4. In a "foreach" control construct in a shell script, the ":q" modifier can be used to retain the quoting for an argument list. Here is a simple example:
<129 arctic:~ > cat showargs
#!/bin/tcsh -f
foreach item ($argv[*]:q) echo $item end
<130 arctic:~ > showargs aaa bbb "ccc ddd" eee aaa bbb ccc ddd eee