CS 1313 010: Computer Programming, Spring 2000 Programming Project #1: Thinking of a Number Due in class Thursday 27 January 2000 For online help check the class website http://www.ecn.ou.edu/cs1313010/ You can get help with this assignment during your Friday lab sessions. This first assignment will help you learn to use the Engineering Computer Network (ECN). A personal account should have been set up for you automatically, but if you have trouble accessing your account, you should talk to your TA or e-mail hneeman@ou.edu by no later than Friday January 21. You must be enrolled in the class to get an account. The requirements for this assignment are: 1. Log on to your personal account. You can do this in a couple of ways: (a) Log on via a PC in Carson 206 or one of the other ECN labs. Your account name is your OU 4+4 username; your password should be your OU mail account password. (b) Log on via your laptop s wireless connection. 2. Connect and log on to a DEC Alpha running the Unix operating system, either: (a) Via QVTNet: Start -> Internet Utilities -> QVTNet Connect to host ecnalpha.ecn.ou.edu (b) Via Telnet: Start -> Run, then type telnet ecnalpha.ecn.ou.edu You should get a prompt for your username and password, something like this: Trying 129.15.112.37... Connected to ecnalpha.ecn.ou.edu. Escape character is ^]. Digital UNIX (vinson.ecn.ou.edu) (ttyp0) login: neeman Password: noneofyourbusiness [invisible] Once you log on, you ll get a page or two of information, and at the bottom will be a Unix prompt, probably a percent sign, with the cursor after it: %
3. Create a subdirectory called CS1313, like so (all commands should be followed by pressing the Enter or Return key): % mkdir CS1313 4. Set the permissions on your CS1313 directory so that only you can access it: % chmod u=rwx,go= CS1313 Your CS1313 directory is now accessible only to you. 5. Go into your CS1313 directory: % cd CS1313 All of your programming projects should reside in your CS1313 directory. 6. Aside: to learn more about a particular Unix command, type: % man commandname For example, % man chmod will give you the online manual page for the chmod command. 7. Copy the Fortran 90 program mynumber.f90 from Dr. Neeman s home directory to your CS1313 directory: % cp ~neeman/mynumber.f90. 8. Confirm that you have mynumber.f90 in your CS1313 directory by listing the directory s contents: % ls mynumber.f90 9. Using the text editor of your choice (e.g., pico, vi), edit mynumber.f90: % pico mynumber.f90 (a) In the comment block at the top of the file, change the author name, lab section and time. (b) Change the values assigned to minnum, maxnum and mynum. You can select any integer values you want, as long as minnum < mynum < maxnum. (c) Change the following output strings to your own words: i. Hey! That s not between ii. That s amazing! iii. Close, but no cigar iv. Bzzzt! My number was 10. Compile the program: % f90 -o mynumber mynumber.f 11. If the program doesn t compile, you ll need to edit it and figure out where things went wrong. In the worst case, if you re totally stumped, go back and copy the original from Dr. Neeman s home directory again, and start editing from scratch.
12. Once you have the program compiled, test it: 5 That s amazing! 13. If the program doesn t run, you ll need to edit it and figure out where things went wrong. In the worst case, if you re totally stumped, go back and copy the original from Dr. Neeman s home directory again, and start editing from scratch. 14. Once the program compiles and runs properly, start a script: % script mynumber.script Script started, file is mynumber.script 15. List the contents of the directory, using the long listing -l option: % ls -l -rwxr-xr-x 1 neeman faculty 32768 Jan 12 19:44 mynumber -rw-r--r-- 1 neeman faculty 2258 Jan 12 19:43 mynumber.f90 16. Output your program: % cat mynumber.f This will cause the contents of mynumber.f to be sent to the terminal screen. 17. Compile your program: % f90 -o mynumber mynumber.f 18. Run it, choosing the following values: (a) An integer value less than minnum or greater than maxnum (b) An integer value between minnum and maxnum (inclusive), but far from mynum (c) The integer value one less or one more than mynum (d) The value of mynum It ll look similar to this: 0 Hey! That s not between 1 and 10! 2 Bzzzt! My number was 5.
6 Close, but no cigar; I had 5. 5 That s amazing! 19. End the script by typing Control-D (hold down the Ctrl key, and while holding it down press the D key): % ctrl-d Script done, file is mynumber.script 20. Check to make sure that you have a file called mynumber.script: % ls mynumber mynumber.f90 mynumber.script 21. Print your script file: % lpr -P<printername> mynumber.script but replace <printername> with the name of the printer you want to print to, which you can find on the sign attached to that printer. Laptop users: if you want to print the file at home, you ll have to download the file to your laptop s hard drive. 22. Using a word processor, text editor or typewriter of your choice, create a cover page with the following information: (a) Project number and name (b) Course number, name and semester (c) Author name and student ID (d) Lab section, day and time For example: Project #1: Thinking of a Number CS 1313 010: Computer Programming, Spring 2000 Sandy Lee 123-45-6789 Lab Section 013 Friday 2:30pm 23. Print up a brief summary of the project and of your results, in your own words. 24. Bind the cover sheet, summary sheet, and all pages of the script printout with at least an adequate staple. No paper clips, duct tape, brightly colored yarn, etc.
Notes You will use this same process for every programming project in this class. Since your programming projects are 55% of your grade, each one is worth over 5%. You ll want to do them all. You are expected to keep a copy of your source code and your script file on your ECN account through the end of the semester. Do not delete either file! If something goes wrong with your printout, those files will be your only proof that you ve done the work. We urge you to go to your lab session every week. Your TA will be happy to help you with your programming projects. You can get help with Unix, laptops, software and so on from: http://www.ecn.ou.edu/helpdesk/