Question

You are asked to develop a Visual Basic Net application that can determine roots of a requirements of this project are as follows: 1) Design a form to allow users to define a quadratic equation and to find the roots of the equation. The form should have a label that shows this message: Solving a quadratic equation ax2+bx+c=0 The form should have three textboxes in which users enter the values of a, b, and c The form should have two more textboxes in which the roots are displayed. The form should have three buttons: Calculate, Clear, and Exit Quadratic Equation E3 Solving a quadratic equation aX2 + b*x +c = 0 lol 04 Clear Exit 2) When the Calculate button is clicked, the roots are calculated and displayed. The application should be able to determine both real and imaginary roots. 3) When the Clear button is clicked, all the textboxes will be cleared. 4) When the Exit button is clicked, the application is closed.Visual Basic

0 0
Add a comment Improve this question Transcribed image text
Answer #1

VB.Net Application:

File: Form1.Designer.vb

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.txt_a = New System.Windows.Forms.TextBox()
        Me.txt_b = New System.Windows.Forms.TextBox()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.txt_c = New System.Windows.Forms.TextBox()
        Me.Label5 = New System.Windows.Forms.Label()
        Me.txt_x1 = New System.Windows.Forms.TextBox()
        Me.Label6 = New System.Windows.Forms.Label()
        Me.txt_x2 = New System.Windows.Forms.TextBox()
        Me.Label7 = New System.Windows.Forms.Label()
        Me.btnCalculate = New System.Windows.Forms.Button()
        Me.btnClear = New System.Windows.Forms.Button()
        Me.btnExit = New System.Windows.Forms.Button()
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label1.Location = New System.Drawing.Point(140, 25)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(237, 20)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Solving a quadratic equation"
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label2.Location = New System.Drawing.Point(168, 45)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(156, 20)
        Me.Label2.TabIndex = 1
        Me.Label2.Text = "a*x^2 + b*x + c = 0"
        '
        'Label3
        '
        Me.Label3.AutoSize = True
        Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label3.Location = New System.Drawing.Point(62, 106)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(22, 18)
        Me.Label3.TabIndex = 2
        Me.Label3.Text = "a:"
        '
        'txt_a
        '
        Me.txt_a.Location = New System.Drawing.Point(100, 104)
        Me.txt_a.Name = "txt_a"
        Me.txt_a.Size = New System.Drawing.Size(55, 20)
        Me.txt_a.TabIndex = 3
        '
        'txt_b
        '
        Me.txt_b.Location = New System.Drawing.Point(233, 104)
        Me.txt_b.Name = "txt_b"
        Me.txt_b.Size = New System.Drawing.Size(55, 20)
        Me.txt_b.TabIndex = 5
        '
        'Label4
        '
        Me.Label4.AutoSize = True
        Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label4.Location = New System.Drawing.Point(195, 106)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(22, 18)
        Me.Label4.TabIndex = 4
        Me.Label4.Text = "b:"
        '
        'txt_c
        '
        Me.txt_c.Location = New System.Drawing.Point(365, 104)
        Me.txt_c.Name = "txt_c"
        Me.txt_c.Size = New System.Drawing.Size(55, 20)
        Me.txt_c.TabIndex = 7
        '
        'Label5
        '
        Me.Label5.AutoSize = True
        Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label5.Location = New System.Drawing.Point(327, 106)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(22, 18)
        Me.Label5.TabIndex = 6
        Me.Label5.Text = "c:"
        '
        'txt_x1
        '
        Me.txt_x1.Location = New System.Drawing.Point(106, 173)
        Me.txt_x1.Name = "txt_x1"
        Me.txt_x1.Size = New System.Drawing.Size(117, 20)
        Me.txt_x1.TabIndex = 9
        '
        'Label6
        '
        Me.Label6.AutoSize = True
        Me.Label6.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label6.Location = New System.Drawing.Point(62, 175)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(45, 18)
        Me.Label6.TabIndex = 8
        Me.Label6.Text = "x1 = "
        '
        'txt_x2
        '
        Me.txt_x2.Location = New System.Drawing.Point(330, 173)
        Me.txt_x2.Name = "txt_x2"
        Me.txt_x2.Size = New System.Drawing.Size(117, 20)
        Me.txt_x2.TabIndex = 11
        '
        'Label7
        '
        Me.Label7.AutoSize = True
        Me.Label7.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label7.Location = New System.Drawing.Point(286, 175)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(45, 18)
        Me.Label7.TabIndex = 10
        Me.Label7.Text = "x2 = "
        '
        'btnCalculate
        '
        Me.btnCalculate.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btnCalculate.Location = New System.Drawing.Point(32, 272)
        Me.btnCalculate.Name = "btnCalculate"
        Me.btnCalculate.Size = New System.Drawing.Size(123, 35)
        Me.btnCalculate.TabIndex = 12
        Me.btnCalculate.Text = "Calculate"
        Me.btnCalculate.UseVisualStyleBackColor = True
        '
        'btnClear
        '
        Me.btnClear.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btnClear.Location = New System.Drawing.Point(179, 272)
        Me.btnClear.Name = "btnClear"
        Me.btnClear.Size = New System.Drawing.Size(123, 35)
        Me.btnClear.TabIndex = 13
        Me.btnClear.Text = "Clear"
        Me.btnClear.UseVisualStyleBackColor = True
        '
        'btnExit
        '
        Me.btnExit.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btnExit.Location = New System.Drawing.Point(324, 272)
        Me.btnExit.Name = "btnExit"
        Me.btnExit.Size = New System.Drawing.Size(123, 35)
        Me.btnExit.TabIndex = 14
        Me.btnExit.Text = "Exit"
        Me.btnExit.UseVisualStyleBackColor = True
        '
        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(508, 369)
        Me.Controls.Add(Me.btnExit)
        Me.Controls.Add(Me.btnClear)
        Me.Controls.Add(Me.btnCalculate)
        Me.Controls.Add(Me.txt_x2)
        Me.Controls.Add(Me.Label7)
        Me.Controls.Add(Me.txt_x1)
        Me.Controls.Add(Me.Label6)
        Me.Controls.Add(Me.txt_c)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.txt_b)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.txt_a)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.Name = "Form1"
        Me.Text = "Quadratic Equation"
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents txt_a As System.Windows.Forms.TextBox
    Friend WithEvents txt_b As System.Windows.Forms.TextBox
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents txt_c As System.Windows.Forms.TextBox
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents txt_x1 As System.Windows.Forms.TextBox
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents txt_x2 As System.Windows.Forms.TextBox
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents btnCalculate As System.Windows.Forms.Button
    Friend WithEvents btnClear As System.Windows.Forms.Button
    Friend WithEvents btnExit As System.Windows.Forms.Button

End Class

File: Form1.vb

Public Class Form1

    ' Clear button click event handler
    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click

        ' Clearing values
        txt_a.Clear()
        txt_b.Clear()
        txt_c.Clear()
        txt_x1.Clear()
        txt_x2.Clear()

    End Sub

    ' Exit button click event handler
    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click

        Application.Exit()

    End Sub

    'Calculate button click event handler
    Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click

        Dim a, b, c, x1, x2 As Double

        'Fetching values from textbox
        a = txt_a.Text
        b = txt_b.Text
        c = txt_c.Text

        Dim det As Double

        'Calculating determinant
        det = (b * b - 4 * a * c)

        ' If determinant is greater than 0
        If (det > 0) Then

            ' Calculating real part
            x1 = (-b + Math.Sqrt(det)) / (2 * a)
            x2 = (-b - Math.Sqrt(det)) / (2 * a)

            ' Writing results to text boxes
            txt_x1.Text = x1.ToString("0.00")
            txt_x2.Text = x2.ToString("0.00")
   
        ElseIf det = 0 Then

            ' Calculating real part
            x1 = x2 = (-b + Math.Sqrt(det)) / (2 * a)

            ' Writing results to text boxes
            txt_x1.Text = x1.ToString("0.00")
            txt_x2.Text = x2.ToString("0.00")

        Else

            Dim img1, img2 As Double

            'Calculating real part
            x1 = -b / (2.0 * a)
            x2 = -b / (2.0 * a)

            'Calculating imaginary part
            img1 = (Math.Sqrt(-det) / (2.0 * a))
            img2 = (Math.Sqrt(-det) / (2.0 * a))

            ' Writing results to text boxes
            txt_x1.Text = "(" + x1.ToString("0.00") + ") + i (" + img1.ToString("0.00") + ")"
            txt_x2.Text = "(" + x2.ToString("0.00") + ") - i (" + img2.ToString("0.00") + ")"

        End If

    End Sub

End Class

_______________________________________________________________________________________________

Sample Run:

Quadratic Equation Solving a quadratic equation a 7 b: 9 C: 8 x1 = (0.64) + i (-0.85) x2 (0.64)-i (0.85) Calculate Clear Exit

Add a comment
Know the answer?
Add Answer to:
Visual Basic You are asked to develop a Visual Basic Net application that can determine roots...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • quadratic equation by PHP The purpose of this question is to develop a simple calculator for...

    quadratic equation by PHP The purpose of this question is to develop a simple calculator for solving a quadratic equation of the form . The solution of the quadratic equation can be classified as a real or an imaginary solution. In this question you are required to apply two formulas for solving the quadratic equation; the discriminant formula and quadratic formula. The discriminant formula is applied for determining whether the quadratic equation has a real or imaginary solution, where the...

  • create an application in VISUAL BASIC that calculates a cars gas mileage. The formula for calculating...

    create an application in VISUAL BASIC that calculates a cars gas mileage. The formula for calculating the miles that a car can travel per gallon of gas is MPG = Miles/Gallon In the formula MPG is miles-per-gallon, miles is the number of miles that can be driven on a full tank of gas, and gallons is the number of gallons that the tank holds. The applications form should have TextBox controls that let the user enter the number of gallons...

  • How do you do this using visual studio on a Mac? You are tasked with creating...

    How do you do this using visual studio on a Mac? You are tasked with creating an application with five PictureBox controls. In the Poker Large folder, you will find JPEG image files for a complete deck of poker cards. Feel free to choose any card image that you like or be creative with this application. Each PictureBox should display a different card from the set of images. When the user clicks any of the PictureBox controls, the name of...

  • Project 2 Description Create a Visual C# project that when an employee's biweekly sales amount is...

    Project 2 Description Create a Visual C# project that when an employee's biweekly sales amount is entered and the Calculate button is pressed, the gross pay, deductions, and net pay will be displayed. Each employee will receive a base pay of $1200 plus a sales commission of 8% of sales. Once the net pay has been calculated, display the budget amount for each category listed below based on the percentages given.         base pay = $1200; use a named...

  • PLEASE USE VISUAL BASIC* BY VISUAL STUDIO. Visual Basic INTERMEDIATE Create a Windows Forms application. Use...

    PLEASE USE VISUAL BASIC* BY VISUAL STUDIO. Visual Basic INTERMEDIATE Create a Windows Forms application. Use the following names for the project and solution, respectively: Chopkins Project and Chopkins Solution. Save the application in the VB2017\Chap03 folder. Change the form file's name to Main Form.vb. Change the form's name to frmMain. Create the interface shown in Figure 3-37. The interface contains six labels, three text boxes, and two buttons. The application calculates and displays the total number of packs ordered...

  • Please help! Visual Basic - Windows App Form .NET Framework. ​Option Explicit ON ​Option Strict ON...

    Please help! Visual Basic - Windows App Form .NET Framework. ​Option Explicit ON ​Option Strict ON ​Option Infer ON calculate Letter Grade Number grade: I Letter grade: Calculate Exxt Start a new Project named GradeConverter Add labels, textboxes, and button to the default form. Create an event handler for Calculate and Exit. . When the user enters a number- between 0.0 and 100.0 and clicks Calculate, the letter grade will display for the user The form should be able to...

  • Need help!!! I need two programs that use one common database.. One program using a Visual...

    Need help!!! I need two programs that use one common database.. One program using a Visual Basic windows form using textboxes for data input (first name, last name, phone, email) and it should save the info into an SQL database when a save button is clicked. Second program using a C# windows form that has a drop down menu with all the names that have been saved into the database, when one name is clicked all their information should pop...

  • A fitness tracking app company has asked you to develop a windows application using a GUI...

    A fitness tracking app company has asked you to develop a windows application using a GUI to determine the total amount of hours somebody has exercised during their lifetime, assuming on average a user has exercises 2.5 hours per week. When the user uses the app, they will enter the following: First Name: Last Name: Date of Birth (in mm/dd/yyyy): Current Date (in mm/dd/yyyy) This program should display the users name and the number of hours the user has exercised...

  • Visual Basic Programming Step 1-2 not important, it's just file naming.

    Visual Basic Programming Step 1-2 not important, it's just file naming. 3. Form contains nine Labels, one TextBox, and three Button controls. You use labels to let user know what to enter and what will be displayed; TextBoxes to input a number between 1 and 99. Buttons to Calculate change. Clear Input and Exit program. See below Form Layout with Controls for more details 4. Declare variables to store the entered value in TextBox, and what will be displayed in...

  • Visual Basic Programming Step 1-2 not important, it's just file naming. 3. Form contains nine Labels,...

    Visual Basic Programming Step 1-2 not important, it's just file naming. 3. Form contains nine Labels, one TextBox, and three Button controls. You use labels to let user know what to enter and what will be displayed; TextBoxes to input a number between 1 and 99. Buttons to Calculate change. Clear Input and Exit program. See below Form Layout with Controls for more details 4. Declare variables to store the entered value in TextBox, and what will be displayed in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT