Prelude to Programming: Errata for Extended Version. [Note: Changes from the
text are bolded]. Chapter 0: p. 23: Review Q. 17: The answer should be compiler,
...
Prelude to Programming: Errata for Extended Version [Note: Changes from the text are bolded]
Chapter 0: p. 23: Review Q. 17: The answer should be compiler, not FORTRAN
Chapter 1: p. 34: Example 1.1 Using BASIC to Code the Currency Converter
• • • •
1. PRINT “Enter the price in pounds: “ 2. INPUT PoundPrice 3. LET DollarPrice = 1.62 * PoundPrice 4. PRINT DollarPrice 5. END Lines 1 and 2 ask the user to enter the price and that number is stored in PoundPrice. Line 3 does the conversion. It multiplies the PoundPrice by 1.62 and stores the resulting number in a variable named DollarPrice. Line 4 displays the answer. Line 5 is how BASIC says the end
p. 35: The last 3 bullets under the explanation of Example 1.2 should read: • Line 6 does the conversion. It multiplies the PoundPrice by 1.62 and stores the resulting number in a variable named DollarPrice. Note that this line does exactly the same thing as line 3 in the BASIC program, and it virtually looks the same. It is the essence of this program! The actual calculation, which is mainly what we wanted when we wrote this program, uses the same logic in both languages. • Line 7 does the same thing as line 4 in BASIC—it displays the resulting conversion of British pounds to U.S. dollars. • Line 8 is how C++ says the end.
Chapter 2: p. 86, Example 2.6: The Complete Sale Price Program Design Main module Declare ItemName As String Declare OriginalPrice, DiscountRate, SalePrice, Tax, TotalPrice As Real Write “Sale Price Program” Write “This program computes the total price, including tax, of” Write “an item that has been discounted a certain percentage.” Call Input Data module
p. 87: Format Output for Readability Sometimes, program output can be improved by skipping a line in certain places. For example, the first four Write statements in the main module of the sale price program produce the following output: Sale Price Program This program computes the total price, including tax, of an item that has been discounted a certain percentage. p. 93: Example 2.9 Displaying a Test Run of the Sale Price Program Once the sale price program of Section 2.2 has been coded, the screen display for a test run might look like the following (user input is in bold ): Sale Price Program This program computes the total price, including tax, of an item that has been discounted a certain percentage. What is the item’s name?
Chapter 4: p. 178: • Repeat • Put the left foot in front of the right foot • Put the right foot in front of the left foot • Until you get across the room This way is short, convenient, and just as descriptive. Even if you want to take hundreds or thousands of steps, the process can still be described in four lines… p. 193: Example 4.6: Countdown to Blastoff Using a Decremental Counter Let’s display a countdown to blastoff for a rocket to the moon. The countdown begins at 100 and counts down to 1 at one-second intervals as follows: p. 199: Examples 4.14 and 4.15 have been renamed for clarity as follows: Example 4.14: Use the Test Condition Carefully: Not Enough Beans Example 4.15: Use the Test Condition Carefully: Too Many Beans
p. 201, under Making It Work VisualBasic code: Private Sub btnBeanCount_Click Dim beans as Integer beans = 4 For Counter = 1 To beans Step 1 Write “bean” Next Counter End Sub
Note: Since Count is a pre-defined function in Visual Basic, it cannot be used as a variable name. Therefore, the counter is named Counter in this example. p. 236: Review Q. 31: A line of code is missing (in bold): Set A = 0 For B = 1 Step 1 to N Set A = A + 2 * B – 1
Set B = B + 1 End For Write A p. 236: Review Q. 34: The flowchart should look as follows:
p. 236: Review Q. 36: The answer should be: 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 p. 237: Review Q. 39: The answer should be: Hello Hello
p. 237: Programming Problem 2 The answer should include input statements in the Process Ages Module as follows:
Process Ages module Declare Age As Real Set Counter = 0 Set Sum = 0 Write “Enter an age. Enter 0 when done.” Input Age While Age > 0 Set Counter = Counter + 1 Set Sum = Sum + Age
Write “Enter an age. Enter 0 when done.” Input Age End While
Chapter 5: p.245, under second bullet of explanation of Lines 5-9 in Example 5.1:
However, the first month of the year is Month 1, which is why the Write statement on line 6 asks the user to input the value for Month K + 1. On the first pass, the Write statement asks for Month 1 and on the 12th pass, the Write statement asks for Month 12.
p. 275: The name of Example 5.9 has been changed for clarity to: Example 5.9: Using the Length Function with Character Arrays
Chapter 8 p. 405: In Example 8.2, a program error will result if the main program calls the subprogram ComputeVolume before its Side attribute is given a value. p. 438, Under Self Check 8.21, last bulleted item: • The array Scores has entries of the form Scores[testnum, studentnum]; for example, Scores[2, 15] holds the score of student 16 on test 3
Chapter 9 p. 466 under the explanation for Example 9.7 Calling Richard: Lines 13–26 complete the search, as described earlier in this section.