Question: Chapter 19 Exercise 15 Locate and Correct Errors The average sales should be $8377.88. We need to locate and correct the errors in the code

Chapter 19 Exercise 15 Locate and Correct Errors

The average sales should be $8377.88. We need to locate and correct the errors in the code below.

Name: SwatTheBugs Project ' Purpose: Display the average quarterly sales ' Programmer: on

Public Class frmMain

Private decQuarterSalesRegion1() As Decimal = {2300.5, 1000, 7500} Private decQuarterSalesRegion2() As Decimal = {4500, 5300.25, 2360} Private decQuarterSalesRegion3() As Decimal = {1000, 2200, 2400} Private decQuarterSalesRegion4() As Decimal = {450.75, 3000, 1500}

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click Me.Close() End Sub

Private Sub btnAverage_Click(sender As Object, e As EventArgs) Handles btnAverage.Click ' calculates and displays the average quarterly sales

Dim decTotalQuarterSales As Decimal ' accumulator Dim decAverageSales As Decimal

' accumulate sales amounts decTotalQuarterSales = 0 For intSub = 1 To decQuarterSalesRegion1.Length - 1 decTotalQuarterSales = decTotalQuarterSales + decQuarterSalesRegion1(intSub) + decQuarterSalesRegion2(intSub) + decQuarterSalesRegion2(intSub) + decQuarterSalesRegion4(intSub) Next intSub

decAverageSales = decTotalQuarterSales / 4 lblAverage.Text = decAverageSales.ToString("C2") End Sub

Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load

End Sub End Class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!