Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Open the SwatTheBugs Solution (SwatTheBugs Solution.sln) file contained in the ClearlyVB2012Chap17SwatTheBugs Solution folder. Open the Code Editor window and study the existing code. Start and

Open the SwatTheBugs Solution (SwatTheBugs Solution.sln) file contained in the ClearlyVB2012\Chap17\SwatTheBugs Solution folder. Open the Code Editor window and study the existing code. Start and then test the application. Notice that the application is not working correctly. Stop the application. Locate and correct the errors in the code. Save the solution and then start and test the application again. Close the Code Editor window and then close the solution.

image text in transcribed

The problem in the code I found is when I enter 10 as dividend and 2 as the divisor, the result says: 10 divided by 2 is 0.2 . ---What are the errors in the code?

Here is the code:

Public Class frmMain

Private Function GetQuotient(ByVal decN1 As Decimal, ByVal decN2 As Decimal) As Decimal ' return the quotient after dividing decN1 by decN2

Dim decQ As Decimal

If decN2 0 Then decQ = decN1 / decN2 End If Return decQ End Function

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

Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click ' display the quotient

Dim strDividend As String Dim strDivisor As String Dim decDividend As Decimal Dim decDivisor As Decimal Dim decQuotient As Decimal

strDividend = InputBox("Enter the dividend:", "SwatTheBugs") strDivisor = InputBox("Enter the divisor:", "SwatTheBugs")

Decimal.TryParse(strDividend, decDividend) Decimal.TryParse(strDivisor, decDivisor) decQuotient = GetQuotient(decDivisor, decDividend) lblQuotient.Text = decDividend.ToString & " divided by " & decDivisor.ToString & " is " & decQuotient.ToString End Sub End Class

frmMain.vb frmMain.vb [Design] n X Start Page SwatTheBugs Calculate Quotient Exit SwatTheBugs Calculate Quotient Exit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Murach's SQL Server 2012 For Developers

Authors: Bryan Syverson, Joel Murach, Mike Murach

1st Edition

1890774693, 9781890774691

More Books

Students also viewed these Databases questions

Question

Rank the following compounds in order of decreasing acidity:

Answered: 1 week ago

Question

=+how might their legitimacy be improved?

Answered: 1 week ago

Question

( 1 5 points ) Give the regular expression for following DFA:

Answered: 1 week ago