Computer Science 111a – Fall Semester, 2001

Homework #1

due: by 1:00 on Sept. 18

Part 1.

First, make a copy of your file graduation.c under the new name hw1.c: type cp graduation.c hw1.c (that's a "one", not an "ell").  If you now type ls, you will see that you have a new file called hw1.c

Use emacs to make the following changes in hw1.c:

a. Change the author to include your name, and change the date to the date on which you do this part of the project. Also, before submitting, change the description to reflect the modifications that you have made.

b. Delete the line that says: #define this_year 2001 and add a line that defines January_months to be 4 (we will subtract 4 months if the user is graduating in January rather than May).

c. In the line that says int graduation_year, num_months;, add this_year and January (separated with commas)

d. Add 4 new lines after the line that says scanf ("%d", &graduation_year): The first new line will be a printf statement that asks the user what the current year is -- it will be very similar to the line that asks her when she graduates. The second new line will be a scanf statement using this_year instead of graduation_year.  The third line will be a printf that asks the user whether she graduates in January, telling her to enter 1 for yes and 0 for no.  The fourth line will be a scanf statement using January.

e. In the line that says char first_initial, last_initial; add middle_initial (as above).

f. Change the line that asks the user for her initials, so that it will now ask her for 3 initials (first, middle, and last).

g. Change the scanf that gets the initials so that it will get the middle initial along with the other two.

h. Change the lines that print the initials so that all three of the user's initials get printed.

i.  Change the line that computes the number of months until graduation, by subtracting January times January_months.

j. Change the introductory and goodbye remarks that get printed on the screen by the program. Have fun -- you might make the program funny, sassy, academic, enigmatic.

BE SURE to compile and test your program and make sure that it doesn't have any bugs!

To get a printout (hard copy) of your program, type print hw1.c  You will then be asked to choose a printer.  Remember that UNIX is case-sensitive, so you will need to use capital letters as indicated.

When your program is ready, you should submit your file electronically by issuing the command

submit hw1 hw1.c

To make sure that it was submitted, you can enter ls ~111a/handin.  If you see your account name there, the submit command worked correctly.

Part 2.

Send a mail message to me (111a), telling me about your previous experience with computers, why you are taking this course, and what you hope to learn. When I get your message I will send you a reply.