HOMEWORK 2

You can do problem one for just a C in this assignment set. You can do any other problem for a B in this assignment set. You can do any two problems from two through four below for an A on this assignment set.

problem 1

write a csh program, TwoC. It will insert the last line of the file indicated by the first argument into the first position in each subsequent file name listed as an argument.

For example, if the files were:

cat
meow
furry
adorable

milly
8 year old
black

felis
male
tabby
short-furred


and you typed TwoC cat milly felis , then these two files would changed as indicated below:
milly
meow
8 year old
black

felis
meow
male
tabby
short-furred

Problem Two

This is an extension of Problem One.

The csh program, twoB takes groups of file names. Each group will be separated from the next item in the group by a slash. The first item in each group will be a line number, n. The second item in each group will be a h or t meaning to add at the beginning or end. The third item will be the file name for input. The remaining items will be file names to which to add. twoB will extract the nth line from the input file and add it to hte beginning or end of each other file in the group.

For example, if the files were:

cat
meow
furry
adorable

milly
8 year old
black

felis
male
tabby
short-furred

dog
bark
lovable
four-legged

fido
8 year old
black

rufus
male
german shepard
short-furred

and you typed the command twoB 1 h cat milly felis / 2 t dog rufus fido The files will be:
milly
meow
8 year old
black

felis
meow
male
tabby
short-furred

fido
8 year old
black
lovable

rufus
male
german shepard
short-furred
lovable

Problem Three

Note, this starts a series of problems. You will build upon this in your Set four and again in your CGI/WEB Page assignment.

Your program is to process directory which has a subdirectory for each teacher. Each teacher subdirectory will contain a subdirectory for each course that the teacher is teaching. And the course subdirectory will contain a file for each student of the form first_name.last_name. This file will contain a list of grades, one per line. Each line will contain the assignment name, a vertical bar, and a grade.

It will also contain a file weights containing the weight of each assignment. This will contain for each assignment, the name, a vertical bar, and the weight.

Your program assignWeight is to append the weight information for each assignment to the line with the grade. It will put this in a file name of the form: first_name.last_name.weighted. It will also enter a line for each assignment that the student didn't do. It will have a grade of zero.

(In Assignment Set Four, you will use awk to process these to compute grades)

In the figure below, we would add the following files:

Dr.Bowen/CS310/Jill.Smith.weighted

E1|75|100
E2|75|100
F1|150|200
H|37|50

Dr.Bowen/CS310/Robert.Johnson.weighted

E1|50|100
E2|50|100
F1|100|200
H|25|50

Dr.Bowen/CS245/Jill.Smith.weighted

E1|100|100
E2|100|100
F1|200|200
H|50|50
X3|100|100

Dr.Leff/CS375/Robert.Johnson.weighted

A1|4|4
A2|4|4
A3|4|4
A4|4|4
F1|12|12

Dr.Leff/CS375/Jill.Smith.weighted

A1|3|4
A2|3|4
A3|3|4
A4|0|4
F1|9|12

Use the join command. Remember that the join command requires that both input files be sorted. Also, learn the option for join so that if a student doesn't have a grade recorded for a particular assignment, a zero record gets created.

h=0.25
w=1.0
dim1=1.0
D:box height h width w "d" invisible;
DBowen:box height h width w "Dr. Bowen" invisible with .c at D+(-2*dim1,-dim1);
DLeff:box height h width w "Dr. Leff" invisible with .c at  D+(dim1,-dim1);
arrow from D.s to DBowen.n;
arrow from D.s to DLeff.n;
CS310: box height h width w "CS310" invisible with .c at DBowen+(-dim1,-dim1);
CS245:box height h width w "CS245" invisible with .c at DBowen+(dim1,-dim1);
arrow from DBowen.s to CS310.n;
arrow from DBowen.s to CS245.n;
Weights310: box h*5 width w "weights" "E1|100" "E2|100" "F1|200" "H|50" invisible with .n at CS310+(-dim1,-dim1);
arrow from CS310.s to Weights310.n;
JillSmith: box h*5 width w "Jill.Smith" "E1|75" "E2|75" "F1|150" "H|37" invisible with .n at CS310+(0,-dim1);
RobertJohnson: box h*5 width w "Robert Johnson" "H|25" "E2|50" "E1|50" "F1|100"  invisible with .n at CS310+(dim1,-dim1);
Weights245: box h*6 width w "weights" "X3|100" "E1|100" "E2|100" "F1|200" "H|50" invisible with .n at CS245+(0,-dim1);
arrow from CS310.s to RobertJohnson.n;
arrow from CS310.s to JillSmith.n;
arrow from CS245.s to Weights245.n;
JillSmithx: box h*7 width w "Jill.Smith" "E1|100" "E2|100" "F1|200" "H|50" "X3|100" invisible with .n at CS245+(dim1,-dim1);
CS375: box height h width w "CS375" invisible with .c at DLeff+(0,-dim1);
arrow from CS245.s to JillSmithx.n;
JillSmithy: box h*7 width w "Jill.Smith" "A1|3" "A2|3" "F1|9" "A3|3" "A4|3" invisible with .n at CS375+(0,-3*dim1);
arrow from CS375.s to JillSmithy.n;
RobertJohnsony: box h*6 width w "Robert.Johnson" "A1|4" "A2|4" "F1|12" "A3|4" "A4|4" invisible with .n at CS375+(dim1,-2*dim1);
arrow from CS375.s to RobertJohnsony.n;
Weightsy: box h*6 width w "weights" "F1|12" "A1|4" "A2|4" "A3|4"  invisible with .n at CS375+(dim1,-1*dim1);
arrow from CS375.s to Weightsy.n;

Problem Four

This program uses the same directory structure as shown above.

Write a shell script, search_grade that takes as arguments

It should print out the grade for that student on that assignment in the class. Note that the professor is NOT included. Thus, you need to search each professor's directory.

Example, search_student CS245 Jill Smith F1 would give "F2|100"


Return to Syllabus
E-Mail Dr. Leff
Dr. Leff's Home Page