Programming With Microsoft Visual Basic 2012, Sixth Edition Errata ...

115 downloads 2618 Views 734KB Size Report
Aug 25, 2013 ... Programming With Microsoft Visual Basic 2012, Sixth Edition .... In Figure 7-3, change the procedure header in Example 2 as follows:.
Programming With Microsoft Visual Basic 2012, Sixth Edition Errata Sheet 8/25/2013 Chapter 6 – Pages 380-382 and 384 On page 380 in Chapter 6, replace Figure 6-44 with the following figure: Problem Specification Create an application that displays the balance in a savings account at the end of each of five years, given the amount of money deposited into the savings account at the beginning of the year and using annual interest rates of 3% to 7% in increments of 1%. The interest is compounded annually and no withdrawals or additional deposits are made during any of the years. The interest rate will be entered in decimal form. The application’s interface should provide a Calculate button for displaying the account balances. Pseudocode for the Calculate button’s Click event procedure 1. store deposit in a variable 2. store interest rate in rate variable 2. display Year, Rate, and Balance column headings 3. repeat for years from 1 to 5 in increments of 1 display year number repeat for rates from 3% to 7% in increments of 1% interest = balance * rate add interest to balance balance = deposit * (1 + rate) ^ years display rate and balance end repeat for end repeat for Code for the Calculate button’s Click event procedure Dim dblDeposit As Double Dim dblBalance As Double Double.TryParse(txtDeposit.Text, dblDeposit) txtBalance.Text = "Year" & ControlChars.Tab & "Rate" & ControlChars.Tab & "Balance" & ControlChars.NewLine For intYear As Integer = 1 To 5 txtBalance.Text = txtBalance.Text & intYear.ToString & ControlChars.NewLine For dblRate As Double = 0.03 To 0.07 Step 0.01 dblBalance = dblDeposit * (1 + dblRate) ^ intYear txtBalance.Text = txtBalance.Text & ControlChars.Tab & dblRate.ToString("P0") & ControlChars.Tab & dblBalance.ToString("C2") & ControlChars.NewLine Next dblRate Next intYear Figure 6-44 Problem specification, pseudocode, code, and sample run for another version of the Savings Account application (continues)

(continued) Sample run

use the text box control’s scroll box to view the remaining account balances

Figure 6-44 Problem specification, pseudocode, code, and sample run for another version of the Savings Account application © 2013 Cengage Learning

On page 381 in Chapter 6, make the following modifications to Steps 3 and 9. The modifications are indicated in red. 3. Locate the btnCalc_Click procedure. The procedure contains the Dim statements that declare the dblDeposit and dblBalance variables. It also contains the TryParse method that converts the user’s input (the deposit) to the Double data type. In addition, it contains an assignment statement that displays the “Year”, “Rate”, and “Balance” headings in the txtBalance control. Notice that the assignment statement uses the ControlChars.Tab and ControlsChars.NewLine constants, which represent the Tab and Enter keys, respectively. 9. According to its pseudocode, the procedure should calculate the interest and balance next. Click the blank line below the nested For clause, and then enter the following assignment statement. Press Enter twice after typing the second assignment statement. dblInterest = dblBalance * dblRate dblBalance = dblBalance + dblInterest dblBalance = dblDeposit * (1 + dblRate) ^ intYear

On page 382 in Chapter 6, replace Figure 6-45 with the following figure: Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click ' calculate account balances for each of ' five years, using rates from 3% to 7% ' in increments of 1% Dim dblDeposit As Double Dim dblBalance As Double Double.TryParse(txtDeposit.Text, dblDeposit) txtBalance.Text = "Year" & ControlChars.Tab & "Rate" & ControlChars.Tab & "Balance" & ControlChars.NewLine ' calculate and display account balances For intYear As Integer = 1 To 5 txtBalance.Text = txtBalance.Text & intYear.ToString & ControlChars.NewLine For dblRate As Double = 0.03 To 0.07 Step 0.01 dblBalance = dblDeposit * (1 + dblRate) ^ intYear txtBalance.Text = txtBalance.Text & ControlChars.Tab & dblRate.ToString("P0") & ControlChars.Tab & dblBalance.ToString("C2") & ControlChars.NewLine Next dblRate Next intYear

enter these four lines of code

End Sub Figure 6-45 Completed btnCalc_Click procedure © 2013 Cengage Learning

On page 384 in Chapter 6, replace Figure 6-48 with the following figure: ' calculate and display account balances For intYear As Integer = 1 To 5 txtBalance.Text = txtBalance.Text & intYear.ToString & ControlChars.NewLine For decRate As Decimal = 0.03D To 0.06D Step 0.01D dblBalance = dblDeposit * (1 + decRate) ^ intYear txtBalance.Text = txtBalance.Text & ControlChars.Tab & decRate.ToString("P0") & ControlChars.Tab & dblBalance.ToString("C2") & ControlChars.NewLine Next decRate Next intYear Figure 6-48 Modifications made to the nested loop that controls the interest rates © 2013 Cengage Learning

Chapter 7 - Page 413 In Figure 7-3, change the procedure header in Example 2 as follows: Private Sub DisplaySum(ByVal dblScore1 As Double, ByVal dblScore2 As Double)

Chapter 8 - Pages 512 and 515 On page 512 in Chapter 8: In the DisplayPicture procedure section in Figure 8-38, change “if intNum1 contains:” to “if intIncorrect contains:”. On page 515 in Chapter 8: In Figure 8-42, the Option Explicit On, Option Strict On, and Option Infer Off statements were added to the Frankenstein Game application’s Main Form.vb file.

Chapter 9 - Page 577 In the last line in Figure 9-46, change dblPrices to dblSales.

Chapter 10 - Pages 597-599 On page 597 in Chapter 10: In the first line in Figure 10-7, change Public Function GetGallons to Private Function GetGallons. On page 598 in Chapter 10: Change Step 6 to Private Function GetGallons(ByVal pool As Dimensions) As Double. On page 599 in Chapter 10: In Figure 10-8, change Public Function GetGallons to Private Function GetGallons.

Chapter 11 – Pages 649, 651, and 658 On page 649 in Chapter 11: In Figure 11-6, change Public Function GetGallons to Private Function GetGallons. On page 651 in Chapter 11: In Figure 11-9, change Public Function GetGallons to Private Function GetGallons. On Page 658 in Chapter 11: In the seventh line in the Constructors section, change “A class that contains one or more parameters” to “A constructor that contains one or more parameters”.

Appendix A – Pages 879, 884-886, 890, 892 On Page 879 in Appendix A, change Step 3 to the following: 3. Start the application. If a dialog box similar to the one shown in Figure A-3 appears, click the No button. (If you are using the Express Edition, your dialog box’s title bar will say Microsoft Visual Studio Express 2012 for Windows Desktop.) On Page 884 in Appendix A, change the first two sentences in Step 5 to thefollowing: You can use either the DEBUG menu’s Step Into option or the F8 key (F11 key if you are using the Express Edition) on your keyboard to tell the computer to execute the highlighted instruction. Press the F8 key (or the F11 key if you are using the Express Edition). On Page 885 in Appendix A, change the fourth sentence in Step 9 to the following: Press F8 (F11 if you are using the Express Edition) to process the procedure header. On Page 885 in Appendix A, change the first sentence in Step 12 to the following: Press F8 (F11 if you are using the Express Edition) to process the TryParse method. On Page 886 in Appendix A, change the third sentence in Step 14 to the following: Press F8 (F11 if you are using the Express Edition) to execute the highlighted statement, and then place your mouse pointer on decDiscount10 in the statement. On Page 890 in Appendix A, add the following to the end of Step 4: (If you are using the Express Edition, the error message appears in a box along with a Break button. Click the Break button.) On Page 892 in Appendix A, change the sentence below the third bullet in the Summary section to the following: Use either the Step Into option on the DEBUG menu or the F8 key (F11 key if you are using the Express Edition) on your keyboard.