0% found this document useful (0 votes)
6 views6 pages

Complex Numbers Addition in VB.NET

This document contains source code for a program that performs addition of complex numbers in various formats (Euler, standard, and polar). It includes code to: 1) Convert user input numbers to the Euler, standard, and polar formats individually 2) Add the real and imaginary components of two complex numbers separately 3) Convert the resulting sum to the three formats and display the output or an error message if invalid input is provided.

Uploaded by

cajaro
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views6 pages

Complex Numbers Addition in VB.NET

This document contains source code for a program that performs addition of complex numbers in various formats (Euler, standard, and polar). It includes code to: 1) Convert user input numbers to the Euler, standard, and polar formats individually 2) Add the real and imaginary components of two complex numbers separately 3) Convert the resulting sum to the three formats and display the output or an error message if invalid input is provided.

Uploaded by

cajaro
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

MACHINE

PROBLEM #1
COMPLEX
NUMBERS:
ADDITION
Submitted by: Roy James Brito
Section: CEIT-03-603E
Submitted to: Engr. Bravo

SOURCE CODE:
Public Class ComplexNumbers
Private Sub Button1_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
Dim xnum1 As Double
Dim ynum1 As Double
Dim zEuler As Double
Dim zDegree As Double
Dim degree As Double
Dim Eulertemp As Double
On Error GoTo error_handler
xnum1 = [Link]
ynum1 = [Link]
zDegree = (([Link](ynum1 / xnum1)) * (180 / [Link]))
degree = [Link](zDegree, 2)
zEuler = [Link]((xnum1 ^ 2) + (ynum1 ^ 2))
Eulertemp = [Link](zEuler, 2)
[Link] = Eulertemp & " e " & degree & ""
[Link] = Eulertemp & " ([ cos " & degree & " )] + [( isin " & degree & ")]"
[Link] = Eulertemp & "" & degree & ""
Exit Sub
error_handler:
[Link] = "Error! Invalid Input , number only"
[Link] = "Error! Invalid Input , number only"
[Link] = "Error! Invalid Input , number only"
End Sub
Private Sub Button2_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
Dim xnum2 As Double
Dim ynum2 As Double
Dim wEuler As Double
Dim wDegree As Double
Dim degree As Double
Dim Eulertemp As Double
On Error GoTo error_handler1
xnum2 = [Link]
ynum2 = [Link]
wDegree = (([Link](ynum2 / xnum2)) * (180 / [Link]))

degree = [Link](wDegree, 2)
wEuler = [Link]((xnum2 ^ 2) + (ynum2 ^ 2))
Eulertemp = [Link](wEuler, 2)
[Link] = Eulertemp & " e " & degree & ""
[Link] = Eulertemp & " ([ cos " & degree & " )] + [( isin " & degree & " )]"
[Link] = Eulertemp & "" & degree & ""
Exit Sub
error_handler1:
[Link] = "Error! Invalid Input , number only"
[Link] = "Error! Invalid Input , number only"
[Link] = "Error! Invalid Input , number only"
End Sub
Private Function AddReal() As Double
Dim x1 As Double
Dim x2 As Double
Dim x3 As Double
On Error GoTo rj1
x1 = ([Link])
x2 = ([Link])
x3 = x1 + x2
rj1:

[Link] = "Invalid"
[Link] = "invalid"

Return x3
End Function
Private Function Addimagine() As Double
Dim b1 As Double
Dim b2 As Double
Dim b3 As Double
On Error GoTo rj2
b1 = ([Link])
b2 = ([Link])
b3 = b1 + b2
rj2:
[Link] = "Invalid"
[Link] = "Invalid"
Return b3
End Function

Private Sub Button3_Click(ByVal sender As [Link], ByVal e As [Link])


Handles [Link]
Dim xnum3 As Double
Dim ynum3 As Double
Dim xEuler As Double
Dim xDegree As Double
Dim degree As Double
Dim Eulertemp As Double
xnum3 = [Link](Val(AddReal()), 2)
ynum3 = [Link](Val(Addimagine()), 2)
If xnum3 And ynum3 > 0 Then
[Link] = xnum3
[Link] = ynum3
xDegree = (([Link](ynum3 / xnum3)) * (180 / [Link]))
degree = [Link](xDegree, 2)
xEuler = [Link]((xnum3 ^ 2) + (ynum3 ^ 2))
Eulertemp = [Link](xEuler, 2)
[Link] = Eulertemp & " e " & degree & ""
[Link] = Eulertemp & " ([ cos " & degree & " )] + [( isin " & degree & " )]"
[Link] = Eulertemp & "" & degree & ""
MsgBox("you got it!")
Else
[Link] = "Error! Invalid Input , number only"
[Link] = "Error! Invalid Input , number only"
[Link] = "Error! Invalid Input , number only"
MsgBox("Please Enter a Valid Input, 'A Number'", [Link], "ERROR!
ERROR! ERROR! ERROR! ERROR! ERROR!")
End If
End Sub
End Class

OUTPUT:

WHEN YOU INPUT OTHER


CHARACTERS, AN ERROR BOX
APPEARS:

You might also like