QUESTION A: Access the Blacksburg Electronic Village (BEV) Web site [www.bev.net] and answer the following questions. According to the BEV Web site (not according to something you might already know about Blacksburg!):
a. What is BEV (NOT what does BEV stand for)?
b. When was BEV's "official opening"?
c. What percentage of Blacksburg's population is estimated to be using the Internet?
d. Who is the principal of Kipps Elementary School?
QUESTION B: Trace through the following decimal addition algorithm:
Given: m >= 1 and two positive numbers each containing m digits, am-1
am-2 ... a0 and bm-1 bm-2 ...
Wanted: cm cm-1 cm-2 ... c0, where cm cm-1 ... c0 = (am-1 am-2 ... a0)+(bm-1 bm-2 ... b0)
Step 1: Set the value of carry to 0. Step 2: Set the value of i equal to the value 0. Step 3: Repeat the instructions in steps 4 through 6 until the value of i is greater than m-1.Step 4: Add the two digits ai and bi to the current value of carry to get ci. Step 5: If ci >= 10, then reset ci to (ci-10) and reset the value of carry to 1; otherwise, set the new value of carry to 0. Step 6: Add 1 to i, effectively moving one column to the left.Step 7: Set cm to the value of carry. Step 8: Print out the final answer, cm cm-1 cm-2 ... c0. Step 9: Stop.
Using the following input values:
m = 3 a2 = 1 a1 = 4 a0 = 9
b2 = 0 b1 = 2 b0 = 9
At each step, show the values for c3, c2, c1, c0, and carry.
This answer should be in a tabular form as shown below, with one line listed for each step that executes. Hints: Some steps may execute more than once, some steps may not execute at all. At some points during execution, it may not be possible to determine the value of some values. If this occurs, indicate that, for example, x is unknown.
|Values of variables|
QUESTION C: Based on the definition of "algorithm" given in class and in the book, is the following an algorithm? Why Not?
Step 1. Go to your bank and withdraw $10. Step 2. Give the money to your Computer Science professor. Step 3. Go to step 1.
QUESTION D: Using only the sequential operations, write an algorithm that inputs four numbers corresponding to scores received on three semester tests and a final examination. Your algorithm should compute and display the average of all four tests, weighing the final examination twice as heavily as a regular test.
QUESTION E: Modify the test-averaging algorithm of the above question so that it inputs 15 test scores rather than 4. There are 14 regular tests and a final examination, which again counts twice as much as a regular test. Use a loop to input and sum the scores.
QUESTION F: We wish to create an algorithm that prints out whether a current student is in elementary (1st - 5th), middle (6th - 8th), or high school (9th - 12th). Does the following algorithm correctly do this? Briefly explain why or why not.
Step 1. If (grade <= 5) then print "this student is in elementary school" Step 2. If (grade <= 8) then print "this student is in middle school" Step 3. Else (grade <= 12) then print "this student is in high school"
Once you have completed these questions on paper, you may go to the quiz index at any time. However you should check the time period when the quiz is available. Note that you may check the index of quizzes at any time in WebCT, but once you start into the quiz itself the clock starts.
Go to CS1104 Homepage
Last updated 00/12/12
© J.A.N. Lee, 2000.