Project #2 Solution

$35.00 $29.00

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…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Categorys:
Tags:

Description

5/5 – (2 votes)

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

Be sure to use the specified file names and to submit your files for grading via the CSE Handin system before the project deadline.

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:

Matchwood township

| Ontonagon

|

94

Bois Blanc township

| Mackinac

|

95

Newark township

| Gratiot

|

1093

Vassar township

| Tuscola

|

4093

Westland city

| Wayne

|

84094

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.

You may use UNIX utility programs (such as “echo”, “cat” and “grep”) inside your C shell scripts to generate the reports, but you may NOT use an editor program to edit any of the reports.

All four C shell scripts will write their output to standard output. You may use piping within your scripts to connect the output of one utility program to the input of another, but your scripts may not create any temporary files.

1. The C shell script “proj02.script1” will produce a report about the census units within a specified county.

The report will include an appropriate title, the column headers described above, and all of the census units in a specified county. The places in the county will be sorted by population (from lowest to highest); if more than one place in the county has the same population, the report will list those places alphabetically.

Your C shell script will assume that the second command-line token is an identifier for the specified county (for example, “Ingham” or “Saginaw”).

  1. The C shell script “proj02.script2” will produce a series of reports about the census units in a list of specified counties.

Each report will include an appropriate title, the column headers described above, and all of the census units in a specified county. The places in the county will be sorted by population (from lowest to highest); if more than one place in the county has the same population, the report will list those places alphabetically. Individual reports will be separated by exactly two blank lines.

Your C shell script will assume that the second and each subsequent command-line token is an identifier for a specified county.

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 place 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 (an integer value which is not 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

  1. You may not copy the files containing the data or the column headers into your account. Instead, use absolute pathnames to access the files stored under the “/user/cse325/Projects” directory.

3. The following are examples of valid commands which use the shell scripts:

proj02.script1 Wayne

proj02.script2 “Grand Traverse” Gratiot Wexford

proj02.script3 25 A

proj02.script4 10 C

  1. 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

    1. ddd

eee

  1. Note that some cities appear more than once in the data file. For example:

East

Lansing

city

|

Clinton

|

1969

East

Lansing

city

|

Ingham

|

46610

Multiple entries indicate that parts of the city are located in more than one county. For the purposes of this assignment, you may treat each entry in the data file as a unique record (you don’t need to combine multiple entries for a given city).

Project #2 Solution
$35.00 $29.00