Answers to Self Checks, Extended Prelude to Programming
Extended Prelude to Programming
Third Edition
Answers to Even-numbered Review Exercises
Chapter 0
|2. |ENIAC |20. |d |
|4. |minicomputer |22. |a |
|6. |Web pages |24. |a |
|8. |motherboard |26. |b |
|10. |1024 or 102 |28. |c |
|12. |DVD |30. |False |
|14. |laser |32. |False |
|16. |operating system |34. |True |
|18. |FORTRAN |36. |False |
|20. |b |38. |c, b, a, d |
Chapter 1
|2. |program development cycle |
|4. |data |
|6. |Weight |
|8. |declared |
|10. |character |
|12. |b |
|14. |True |
|16. |True |
|18. |True |
|20. |(a) 4 (b) 100 |
|22. |(a) 4 (b) 0 |
|24. |(a) 234,000 |
| |(b) 0.0000234 |
|26. |Write “Enter your age: “ |
| |Input Age |
|28. |Write “Enter your age: “ |
| |Input Age |
| |Set New = Age – 5 |
| |Write “You don’t look a day over “, New |
|30. |1.25 or 1 |
|32. |No |
|34. |(a) none |
| |(b) Set Number1 = 4 |
| |Set Number1 = Number 1 + 1 |
| |Set Number2 = 3 |
| |Set Number 2 = Number1 * Number2 |
| |(c) Write Number 2 |
|36. |Write “Enter a number: ” |
| |Write “Enter another number: “ |
|38. |Write “The result of the computation is: “ |
|40. |Declare Number1 As Integer |
| |Declare Number2 As Integer |
Chapter 2
|2. |output |
|4. |call |
|6. |pseudocode |
|8. |step |
|10. |logic |
|12. |design documentation or trade study documentation |
|14. |dialog box |
|16. |object-oriented programming |
|18. |b |
|20. |c |
|22. |c |
|24. |c |
|26. |a |
|28. |True |
|30. |False |
|32. |False |
|34. |False |
|36. |True |
|38. |False |
|40. |True |
|42. |True |
|44. |Answers may vary. Some attributes include height, width, color, lock type |
| |Some methods include opening, closing, locking |
|46.. |[pic] |
|48. |Input Data Module |
| |Write “Enter three numbers: “ |
| |Input Number1, Number2, Number3 |
| |Calculate Average Module |
| |Set Average = (Number1 + Number2 + Number3) / 3 |
| |Output Results Module |
| |Write “The average of the numbers ” |
| |Write “Number1, “, “ , Number2, “and “ Number3 |
| |Write “is “, Average |
|50. |Answers will vary. Some possible sets of test data are: |
| |0, 0, 0 or 2, 6, 985 or -253.45, 987, 0 etc. |
Chapter 3
|2. |If-Then-Else |
|4. |d |
|6. |(a) False (b) False (c) True (d) False |
|8. |(a) True (b) False (c) False (d) False |
|10. |False |
|12. |Bye |
|14. |Write “Enter a number: “ |
| |Input NUM |
| |If Num = 1 Then |
| |Write “Yes” |
| |End If |
|16. |[pic] |
|18. |Input Num |
| |If Num = 1 Then |
| |Write “Yes” |
| |End If |
| |If Num 1 Then |
| |Write “No” |
| |End If |
|20. |= , , < , , >= |
|22. |(a) N 5) |
|24. |(a) Input Num |
| |If Num = 1 Then |
| |Write “Yes” |
| |End If |
| |If Num = 2 Then |
| |Write “No” |
| |End If |
| |If Num = 3 Then |
| |Write “Maybe” |
| |End If |
| | |
| |Input Num |
| |If Num = 1 Then |
| |Write “Yes” |
| |Else |
| |If Num = 2 Then |
| |Write “No” |
| |Else |
| |If Num = 3 Then |
| |Write “Maybe” |
| |End If |
| |End If |
| |End If |
| | |
| |(c) Input Num |
| |Select Case of Num |
| |Case 1: |
| |Write “Yes” |
| |Case 2: |
| |Write “No” |
| |Case 3: |
| |Write “Maybe” |
| |End Case |
|26. |multiple alternative structure |
|28. |Input X |
| |If X > 6 Then |
| |Write “Pass” |
| |Else |
| |If (X = 5) OR (X = 6) Then |
| |Write “Retest” |
| |Else |
| |Write “Fail” |
| |End If |
| |End If |
|30. |5 |
| |Not |
| |And |
|32. |(a) 1 (b) 2 (c) 3 |
| |Done Done Done |
|34. |Change the line as follows: If Grade = “A” Then |
|36. |YES |
|38. |the Else clause |
|40. |No |
Chapter 4
|2 |greater than |
|4. |validate |
|6. |(a) True (b) True |
|8. |(a) False (b) True (c) True |
|10. |True |
|12. |False |
|14. |False |
|16. |False |
|18. |2 |
| |1 |
|20. |2 |
| |1 |
|22. |[pic] |
|24. |3 |
| |5 |
| |7 |
|26. |Write “Enter a negative number: “ |
| |Input NegativeNumber |
| |While NegativeNumber >= 0 |
| |Write “Enter a negative number: “ |
| |Input NegativeNumber |
| |End While |
|28. |(a) 1 (b) -1 |
|30. |Write “Enter an integer: “ |
| |Input MyInteger |
| |While MyInteger Int(MyInteger) |
| |Write “Enter an integer: “ |
| |Input MyInteger |
| |End While |
|32. |16 |
|34. |[pic] |
|36. |Set A = 0 |
| |Set Total = 0 |
| |For B = 1 Step 1 To N |
| |Set A = A + 2 * B – 1 |
| |Set Total = Total + (2 * B – 1) |
| |Set B = B + 1 |
| |End For |
| |Write A |
| |Set Average = Total / N |
|38. |4 |
| |5 |
| |8 |
| |10 |
| |12 |
| |15 |
|40. |Hello |
Chapter 5
|2. | 3 |
|4. | 6 |
|6. |True |
|8. |False |
|10. |False |
|12. |False |
|14. |True |
|16. |Declare Numbers[25] |
| |Write “Enter a number. Enter 0 when done.” |
| |Input MyNumber |
| |Set K = 0 |
| |While MyNumber 0 |
| |Set Numbers[K] = MyNumber |
| |Set K = K + 1 |
| |End While |
|18. |4 |
| |1 9 |
|20. |Correct the While statement as follows: |
| |While (Found = 0) AND (Index < N) |
| |Also, change Set Found = 0 inside the If-Then clause to: |
| |Set Found = 1 |
|22. |A[K] = 20, A[K + 1] = 10 |
|24. |Change the If-Then statement to: |
| |If A[K] > A[K + 1] Then |
| |and change the Set Flag = 1 inside the If-Then clause to: |
| |Set Flag = 0 |
|26. |Write Name[0], Name[9] |
|28. |Write Length(FullName) |
|30. |Set First = FullName[0] |
| |For K = 1 Step 1 To 24 |
| |If FullName[K] = “ “ Then |
| |Set Last = FullName[K + 1] |
| |End If |
| |End For |
| |Write First, “.” , Last. “.” |
|32. |Declare Score1[25], Score2[25], Score3[25] As Real |
|34. |For K = 0 Step 1 To 24 |
| |Write Score1[K], Score2[K], Score3[K] |
| |End For |
|36. |For K = 0 Step 1 To 4 |
| |Set Sum = 0 |
| |For J = 0 Step 1 To 4 |
| |Set Sum = Sum + X[K, J] |
| |End For(J) |
| |Write Sum |
| |End For(K) |
|38. |Dewey4 |
| |Dewey5 |
Chapter 6
|2. |fields |
|4. |binary |
|6. |direct access or random access |
|8. |control variable |
|10. |True |
|12. |False |
|14. |True |
|16. |True |
|18. |True |
|20. |False |
|22. |Open “people” For Input As NameFile |
| |While NOT EOF(NameFile) |
| |Read NameFile, PersonName |
| |Write PersonName |
| |End While |
| |Close NameFile |
|24. |“A”,25”C”,20”E”,15 |
|26. |“D”,90 |
|28. |(a) Character, String (b) Integer, Real |
|30. | 5 |
|32. |Shirley and Tamara |
|34. |“Tamara””Shirley””Sam””Michael””Marjorie””Corinne” |
Chapter 7
|2. |exported |
|4. |IPO chart |
|6. |global |
|8. |built-in |
|10. |7 |
|12. |True |
|14. |2 * X ( i.e., 2) ( assigned to Num1 |
| |X (i.e., 1) ( assigned to Num2 |
| |5 ( assigned to Num3 |
|16. |Display: |
| |Input Processing Output |
| |Num1, Num2, Num3 None Num1, Num2, Num3 |
|18. | 2 1 5 |
|20. |Subprogram Flip(X As Refm Y As Ref) |
| |Declare Temp As Real |
| |Set Temp = X |
| |Set X = Y |
| |Set Y = Temp |
| |End Subprogram |
|22. |local: X in Sub, Num1, Num2 |
| |global: X in main, Y |
|24. | 5 |
| |1 |
| |4 |
|26. | 5 |
| |1 |
| |2 |
|28. |(a) 4 (b) 1 |
|30. |(a) “-1.5” (b) 87.6 ,(N=1) |
|32. | 2 |
|34. | 3 |
|36. |Main |
| |Declare X, Y As Real |
| |Write “Enter a number: “ |
| |Input X |
| |Write “Enter another number: “ |
| |Input Y |
| |Write Average(X, Y) |
| |End Program |
|38. |three times |
|40. |Function Fac(N) As Integer |
| |Set Product = 1 |
| |For K = 2 Step 1 To N |
| |Set Product = Product * K |
| |End For |
| |Set Fac = Product |
| |End Function |
|42. |Function Mult(M, N) As Integer |
| |Set Total = 0 |
| |For K = 1 Step 1 To N |
| |Set Total = Total + M |
| |End For |
| |Set Mult = Total |
| |End Function |
Chapter 8
|2. |object |
|4. |Public |
|6. |inheritance |
|8. |parent (or base), child (or derived) |
|10. |d |
|12. |c |
|14. |b |
|16. |True |
|18. |True |
|20. |False |
|22. |False |
|24. |False |
|26. |False |
|28. |SetSide, ComputeArea, GetArea, GetSide |
|30. |Call Square1.SetSide(20) |
|32. |Write “The area is “ Square1.GetArea |
|34. |SetSide, GetArea, GetSide, SetHeight, GetHeight, ComputeArea |
|36. |(a) Text box: Hello |
| |(b) Label objects: The message is: |
|38. |Date |
|40. |name, caption or text, enabled |
|42. |Subprogram OKbutton.Click() |
| |If Option1.Value = True Then |
| |Call Window1.Open |
| |Else |
| |Call Window2.Open |
| |End If |
| |End Subprogram |
|44. |Subprogram EnterButton.Click() |
| |Set Sum = Val(NumberBox.Text) |
| |Set NumberBox.Text = “ “ |
| |End Subprogram |
Chapter 9
|2. |pseudorandom numbers |
|4. |Car.Make, Car.Model |
|6. |indexed |
|8. |(a) True (b) True |
|10. |True |
|12. |True |
|14. |True |
|16. |True |
|18. |False |
|20. |True |
|22. |(a) Random(6) (b) Random(2) – 1 |
|24. |For K = 1 Step 1 To 50 |
| |Write Random(6) |
| |End For |
|26. |(a) 33 = “!” (b) 65 = “A” (c) 126 = “~” |
|28. |(a) “30” (b) “-21.5” |
|30. |Index = 2 |
|32. |1 |
|34. |5 |
|36. |Smith |
|38. |25 bytes (characters) |
|40. |SeekGet DataFile, 1, Car |
| |Write Car.Make, Car.Model |
|42. |Set Last = LOF(DataFile) / Length(Car) |
| |SeekPut DataFile, Last + 1, Car |
|44. |SeekGet DataFile, 10, Car |
| |Set Car.Model = “Explorer” |
| |SeekPut DataFile, 10, Car |
|46. |Set Count = 0 |
| |Set Found = 0 |
| |While (NOT EOF(IndexFile)) AND (Found = 0) |
| |Read IndexFile, Model |
| |Set Count = Count + 1 |
| |If Model = “Camry” Then |
| |Set Car.Make = “ “ |
| |Set Car.Model = “ “ |
| |SeekPut DataFile, Count, Car |
| |Set Found = 1 |
| |End If |
| |End While |
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- english answers to questions
- free answers to any question
- good answers to self evaluation
- good answers to evaluation questions
- answers to homework questions free
- answers to self assessment questions
- answers to self evaluation questions
- how to write an extended definition essay
- answers to self evaluation examples
- answers to a self evaluation
- how to write an extended definition
- checks made payable to estate