Problem 1 (20 points total: 5 points for each question) --------- (a) To be subscribed to a newsgroup implies that this newsgroup is included by default in the set of newsgroups that a news reader (e.g. tin) will check for messages when it is started. An article expires after a certain period of time of its posting. This means that this article cannot be read anymore. (b) CPU = ALU (Arithmetic Logic Unit) + Controller Unlike the CPUs of previous generations, the CPU of a microprocessor fits on a single VLSI chip, making it faster, cheaper, more reliable, more compact, and consuming less energy. (c) telnet MACHINE will start a login session on the computer named MACHINE. telnet tomus will start a login session on the BU campus-wide library. (d) Hard Disk is largest, ROM is smallest, Hard Disk is slowest, and RAM is volatile. (e) ASCII is the American Standard Code for Information Interchange. It's a standard code that allows characters (A-Z, a-z, 0-9, punctuation marks, control characters, etc.) to be represented using 8 bits (1 byte). It is needed to provide a standard so that information could be exchanged easily between computers from different manufacturers. ------------------------------------------------------------------------------ Problem 2 (30 points total) --------- Assume that your login name is student22. Assume that the encircled portion of Figure 1 represents your part of the file hierarchy. Answer the following questions: (a) A friend of yours taking cs101a1 has student 59 as his/her login name. What is the absolute pathname for his/her home directory? (5 points) Answer: /home/course/cs101a1/student59 (b) Label each of the following as a file, directory or "cannot tell". Use Figure 1 and what you know about certain files to answer this question. (6 points-1 point each) Answers: ------- .newsrc file home directory cs101a1 directory hw2 cannot tell hw3 directory Homepage.html file (c) Assume that you have just logged in and that the commands shown below were executed in the order given. What does each one of these commands do? Show any changes that occur to your directory on Figure 1. (14 points-2 points each) Possible Answers: ================ cd cs101 -------- Change to the cs101 subdirectory (it becomes your current directory). mkdir midterm ------------- Make a new directory called "midterm" under the ~student22/cs101 subdirectory. (Changes the picture, i.e., adds a directory called "midterm" under the ~student22/cs101 subdirectory). script solution --------------- Start recording what you type and the output of commands you execute. what is recorded will go in the file called "solution". This command also changes the picture since it creates a file called "solution" in the ~student22/cs101 subdirectory). pwd --- Prints out path of directory where you currently are: /home/course/cs101a1/student22/cs101 exit ---- Stops the script (i.e., stops recording). lpr solution ------------ Sends the solution file to the printer. lpr cs101/hw3/p3 ---------------- Fails, there is no cs101/hw3/p3 under you current directory. (c) What command would you use to make a copy of the file called LetterToMom into the Personal directory. Assume that your current directory is ~student22/cs101/hw1. (5 points) Possible solutions: ================== cp ~/LetterToMom ~/Personal OR cp ../../LetterToMom ../../Personal OR cp ~/LetterToMom ../../Personal OR cp ../../LetterToMom ~/Personal OR ------------------------------------------------------------------------------ Problem 3 (24 points total: 6 points for each question) --------- a. A floppy disk is two-sided, has 50 tracks and 20 sectors, each storing up to 512 bytes. What is the total number of Kilobytes that could be stored on that floppy disk? Total number of bytes = 2 * 50 * 20 * 512 = 1024000 bytes = 1024000/1024 = 1000 Kilobytes b. How many bytes would be needed to store the contents of a 1000-page book? Assume that, on the average, there are 40 lines in a page and 50 characters per line. How many of the floppy disks described in part (a) will be needed to store the book? Total number of characters in the book = 1000 * 40 * 50 = 2000000 Number of floppies needed >= 2000000/1024000 = 1.95 Thus we need two floppies. c. A time-shared computer system allocates 0.025 seconds for each one of the users logged onto it. Assuming that there are 20 users using the system, how many times would a single user be serviced in one minute? Repeat your calculations for the case in which 100 users are using the system. For 20 users: Number of seconds needed to serve all 20 users = 20 * 0.025 = 0.5 Thus in one second, a single user will be serviced 1/0.5 = 2 times, and in one minutes, a single user will be serviced 60/0.5 = 120 times. For 100 users: Number of seconds needed to serve all 100 users = 100 * 0.025 = 2.5 Thus a user is serviced once every 2.5 seconds. Thus in one minute, a single user will be serviced 60/2.5 = 24 times. d. You want to send an e-mail message to your friend John Doe. Unfortunately, you do not know his login name. All you know is that he has an account on a computer called {\em acs.bu.edu}. What command(s) should you use to find his login name? The correct answer is: % finger doe@acs.bu.edu Another answer, which may tell us whether that person has any account at BU is % ph doe ------------------------------------------------------------------------------ Problem 4 (26 points total) --------- Suppose you want a program that takes scores that are out of some amount of points and converts them to percentage scores. For example, if you want to map scores out of 50 points to percentages, a score of 25 would become 50 percent and a score of 40 would become 80 percent. Here is the execution of a program that does just that: % a.out Enter the amount of points scores are out of: 50 Enter a score: 35 70 percent The user first enters 50 meaning that scores that are entered will be out of 50 points. The user is then prompted to enter a score, and when a score of 35 is entered, the program outputs "70 percent" and stops. (a) Write a Pascal program, which when compiled will behave as shown above (18 points): Answer: ------- program calc_percentage; var out_of : integer; score : integer; begin writeln('Enter amount of points scores are out of:'); readln(out_of); writeln('Enter a score:'); readln(score); writeln((score / out_of * 100):3:0, ' percent'); end. ------- (b) Suppose you had a text file named scores.lst that contained the following data: 100 56 What would be the output if you compiled the program you wrote for part (a) and executed it by typing the following at the UNIX prompt? (8 points) % a.out < scores.lst Answer: ------- Enter amount of points scores are out of: Enter a score: 56 percent ------- Note on the program: =================== The program would actually produce the output: 5.60000000000000e+01 percent I.e., the percentage comes out in scientific notation. If you want to print out the number with 3 or fewer digits and with 0 decimal places, you need to do: writeln((score / out_of * 100):3:0, ' percent'); Notice that I've parenthesized the expression and added :3:0 after the parentheses. All the :3:0 does is write out the real number, i.e., the percentage, in 3 spaces with 0 decimal places. Now, you'll get: 56 percent Ok course, I didn't expect anyone to do this, so you didn't lose any points for omitting the :3:0.