Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

4.2 Project II: Roots for a Quadratic Equation roots of ou are asked to develop

ID: 3666013 • Letter: 4

Question

4.2 Project II: Roots for a Quadratic Equation roots of ou are asked to develop a Visual Basic. Net application that can determine uadratic equation. The functional requirements of this projec t are as follows: Design a form to allow users to define a quadratic equation. The have a textbox control created from the textbox control template (see 4-3). This textbox control will allow users to enter a quadratic expressio example, if we want to determine the roots for form should Figure pression. For x2 + 2x+1=0 The textbox control should allow users to enter in the quadratic expression in it: lx 2 +2x+1 Enter a quadratic equation F(x): 1x 2+2x+1 a: b: x2: c: Calculate l Clear Cancel Calculateearcance Figure 4-3 An Example Form for the Project en a quadratic equation is entered in the textbox, the parameters (a. b. ar en a quadratic equation is entered in the textbox, the parameters (a, b, an f the expression should be extracted when users enter the Enter key. T acted parameters are then displayed in the textboxes for ther ectively. Hint: You need to use the KeyPress event to respond tot

Explanation / Answer

'Program:

Private Sub Form_Load()
Text2.Enabled=false
Text3.Enabled=false
Text4.Enabled=false
Text5.Enabled=false
Text6.Enabled=false
End Sub

Private Sub cmdClear_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
End Sub

Private Sub cmdCancel_Click()
Unload Me
End Sub


Private Sub cmdCalculate_Click()
Dim a, b, c As Integer
Dim d, x1, x2 As Double
Dim real, imag as Double
a=val(Text2.Text)
b=val(Text3.Text)
c=val(Text4.Text)
d = b * b – (4 * a * c)
If d>0 Then
Text5.Text = ((-1)*b + Sqr(d)) / (2 * a)
Text6.Text = ((-1)*b - Sqr(d)) / (2 * a)
ElseIf d=0 Then
Text5.Text = (-1)*b/(2*a)
Text6.Text = x1
Else
real= (-1)*b/(2*a);
imag = Sqr((-1)*d)/(2*a);
Text5.Text=real&"+"&imag;
Text6.Text=real&"-"&imag;
End If
End Sub


Private Sub TextBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim F as String
F=Text1.Text
'extract a , b , c from F
'
'
'
End Sub

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote