Using Visual Basic. Max Points Will Be Awarded. You are asked to develop a Visua
ID: 655211 • Letter: U
Question
Using Visual Basic. Max Points Will Be Awarded.
You are asked to develop a Visual Basic.Net application that can determine roots of a quadratic equation. The functional requirements of this project are as follows: Design a form to allow users to define a quadratic equation. The form should have a textbox control created from the textbox control template (see Figure 4-3). This textbox control will allow users to enter a quadratic expression. For example, if we want to determine the roots for x2 + 2x + 1 = 0 The textbox control should allow users to enter in the quadratic expression in it: 1x 2 + 2x+ 1 When a quadratic equation is entered in the textbox, the parameters (a, b, and c) of the expression should be extracted when users enter the Enter key. The extracted parameters are then displayed in the textboxes for them, respectively. You need to use the KeyPress event to respond to the textbox for the quadratic equation. For example, when the textbox is named Func, the event procedure to respond to the KeyPress event to respond to the will be as follow: Private Sub Func-KeyPress(ByVal sender As Object, _ByVal e As System.Windows.Forms.KeyPressEventArgs) _ Handles Func.KeyPress End Sub More information about how to respond to the KeyPress event is provided in Chapter 5. When you are working on this project, you should read Chapter 5 to get a better understanding of VB.Net statements that are related to this project. Once the parameters a, b, and c are extracted from the quadratic equation and displayed in the three designated textboxes, you are asked to calculate the roots and display them on the form. The VB.Net application should have extensive checking capabilities to ensure the roots are calculated accurately. The application should be able to determine both real and imaginary roots.Explanation / Answer
Private Sub Form_Load()Dim a, b, c, det As IntegerDim root1, root2 As SingleDim numroot As IntegerEnd SubPrivate Sub new_Click()' To set all values to zeroCoeff_a.Text = ""Coeff_b.Text = ""Coeff_c.Text = ""Answers.Caption = ""txt_root1.Visible = Falsetxt_root2.Visible = Falsetxt_root1.Text = ""txt_root2.Text = ""Lbl_and.Visible = FalseLbl_numroot.Caption = ""End SubPrivate Sub Solve_Click()a = Val(Coeff_a.Text)b = Val(Coeff_b.Text)c = Val(Coeff_c.Text)'To compute the value of the determinantdet = (b ^ 2) - (4 * a * c)If det > 0 ThenLbl_numroot.Caption = 2root1 = (-b + Sqr(det)) / (2 * a)root2 = (-b - Sqr(det)) / (2 * a)Answers.Caption = "The roots are "Lbl_and.Visible = Truetxt_root1.Visible = Truetxt_root2.Visible = Truetxt_root1.Text = Round(root1, 4)txt_root2.Text = Round(root2, 4)ElseIf det = 0 Thenroot1 = (-b) / 2 * aLbl_numroot.Caption = 1Answers.Caption = "The root is "txt_root1.Visible = Truetxt_root1.Text = root1ElseLbl_numroot.Caption = 0Answers.Caption = "There is no root "End IfEnd Sub - See more at: http://www.vbtutor.net/VB_Sample/QESolver.htm#sthash.ERe6EtpI.dpuf
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.