CS 30 Winter 2008, Homework 2, Due Wed. January 23, 11:59pm. No late homeworks accepted. If you are not finished, turn in what you have done. Remember that each person must do their homework by themselves. Remeber also that you need to get your programs running on a CSIF machine, and do the scripting on a CSIF machine, even if your programs work on some other machines. 1. Modify program celcius.c (which you can get from the class website) to ask the user for two values, the high and the low temperature for a day, both given in farenheight. The program should then compute and output the equivalent high and low temperatures in centigrate. Call the modified program celcius1.c (this naming is crucial for the way your programs will be graded). We have already written our version of celcius1.c. You can run the executable version of it (no, we won't let you look at the source code!) by logging onto a csif machine and then issuing the command ~gusfield/cs30w08/celcius1 Your program should create output that looks EXACTLY like the output of our version of celcius1.c In your program, use one variable for the high temperature and a different variable for the low temperature. Choose variable names that would be meaningful to someone else reading and trying to understand your program. Put in comments to explain how your program works. Run your program many times to test it out with a variety of input. See if you can make it mis-behave by giving it ``degenerate" input (this relies on your creativity). When you are satisfied that your program is correct, start a script session (turn on scripting); cat your program (that is, have it written out on the screen); compile it; execute the program using data 43.8 67.2. The run it again with data -3 7.2. Then exit scripting. The script file is given a name by the system, probably typescript. Rename the script file to celscript. You can look at it with any editor or word processor. Don't worry if it has some ^M symbols at the end of lines. Use handin to send file celcius1.c to cs30a directory p2. Use handin to send file celscript to cs30a directory p2. 2. Modify program celcius1.c to ask the user to input the high and low temperatures for a day, both given in celcius, and then compute and output the equivalent temperatures in farenheight. Call the modified program far1.c (this naming is crucial for the way your programs will be graded). Run your program many times to test it out with a variety of input. See if you can make it mis-behave by giving it ``degenerate" input (this relies on your creativity). Put in comments to explain how your program works. We have already written our version of far1.c. You can run the executable version of it by logging onto a csif machine and then issuing the command ~gusfield/cs30w08/far1 Your program should create output that looks EXACTLY like the output of our version of far1.c When you are satisfied that your program is correct, start a script session (turn on scripting); cat your program (that is, have it written out on the screen); compile it; execute the program using input -8.4 21.5. Then exit scripting. Don't worry if it has some ^M symbols at the end of lines. The script file is given a name by the system, probably typescript. Rename the script file to farscript. You can look at it with any editor or word processor. Use handin to send file far1.c to cs30a directory p2. Use handin to send file farscript to cs30a directory p2. 3. Look at program dist.c on the class website. Although it uses a while statement, which is not covered in the book until a later chapter, program dist.c should be understandable to you. We will talk more about it on thursday. Compile and run it until you fully understand how it works. Now log onto a csif machine and execute the program celcius2.c by typing ~gusfield/cs30w08/celcius2 Modify your program celcius1.c to produce the exact behavior and output given by program celcius2.c Name your modified program celcius2.c Put in comments to explain how your program works. When you are satisfied that your program is correct, start a script session (turn on scripting); cat your program (that is, have it written out on the screen); compile it; execute the program using input 3 -21.5 56.3, then 67 43.2 88.3, then 0. Then exit scripting. Don't worry if it has some ^M symbols at the end of lines. The script file is given a name by the system, probably typescript. Rename the script file to cel2script. Use handin to send file celcius2.c to cs30a directory p2. Use handin to send file cel2script to cs30a directory p2.