Problems: Correcting Code ErrorsThe following samples of code contain errors. Rewrite the incorrect statements to correct all errors.
Private Sub btnCalc_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCalc.Click' calculates and displays the total amount owed for purchasing hats' user enters number of hats and price per hat' all hats are on sale for 25% off the priceDim dblNumHats As IntegerDim decHatPrice As DecimalDim decDiscount As DoubleDim decTotal As Decimal' assign number of hats and price to variablesInteger.TryPurse(txtNumHats.Text, intNumHats)Decimal.TryParse(txtHatPrice, decHatPrice)' calculate and display the total amount oweddecDiscount = decHatPrice * dblRATEdecTotal = (intNumHats + decHatPrice) - decDiscountTotal.Text = decTotal.ToString(C2)End Sub

What will be an ideal response?


Dim intNumHats As Integer

Const dblRATE As Double = 0.25

Integer.TryParse(txtNumHats.Text, intNumHats)

Decimal.TryParse(txtHatPrice.Text, decHatPrice)

decTotal = intNumHats * (decHatPrice - decDiscount)

lblTotal.Text = decTotal.ToString("C2")

Computer Science & Information Technology

You might also like to view...

By default, the tabs on a JTabbedPane appear at the:

a. top. b. bottom. c. left. d. right.

Computer Science & Information Technology

A customer can store purchase information and data on multiple credit cards in an elec- tronic purchasing and storage device called an __________.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

____ statements can be used iteratively to expand the intruder's view of the database and allow further collection of information.

A. Iterative B. Conditional C. Secondary D. Primary

Computer Science & Information Technology

What is the name of the indicator that measures the power of a received wireless signal?

A) WSLM B) LRV C) SNR D) RSSI

Computer Science & Information Technology