Anda di halaman 1dari 6

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 System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
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 = num1.Text
ynum1 = num2.Text
zDegree = ((Math.Atan(ynum1 / xnum1)) * (180 / Math.PI))
degree = Math.Round(zDegree, 2)
zEuler = Math.Sqrt((xnum1 ^ 2) + (ynum1 ^ 2))
Eulertemp = Math.Round(zEuler, 2)
Me.Euler1.Text = Eulertemp & " e " & degree & ""
Me.Standard1.Text = Eulertemp & " ([ cos " & degree & " )] + [( isin " & degree & ")]"
Me.Polar1.Text = Eulertemp & "" & degree & ""
Exit Sub
error_handler:
Me.Euler1.Text = "Error! Invalid Input , number only"
Me.Standard1.Text = "Error! Invalid Input , number only"
Me.Polar1.Text = "Error! Invalid Input , number only"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
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 = num3.Text
ynum2 = num4.Text
wDegree = ((Math.Atan(ynum2 / xnum2)) * (180 / Math.PI))

degree = Math.Round(wDegree, 2)
wEuler = Math.Sqrt((xnum2 ^ 2) + (ynum2 ^ 2))
Eulertemp = Math.Round(wEuler, 2)
Me.Euler2.Text = Eulertemp & " e " & degree & ""
Me.Standard2.Text = Eulertemp & " ([ cos " & degree & " )] + [( isin " & degree & " )]"
Me.Polar2.Text = Eulertemp & "" & degree & ""
Exit Sub
error_handler1:
Me.Euler2.Text = "Error! Invalid Input , number only"
Me.Standard2.Text = "Error! Invalid Input , number only"
Me.Polar2.Text = "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 = (num1.Text)
x2 = (num3.Text)
x3 = x1 + x2
rj1:

num5.Text = "Invalid"
num6.Text = "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 = (num2.Text)
b2 = (num4.Text)
b3 = b1 + b2
rj2:
num5.Text = "Invalid"
num6.Text = "Invalid"
Return b3
End Function

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button3.Click
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 = Math.Round(Val(AddReal()), 2)
ynum3 = Math.Round(Val(Addimagine()), 2)
If xnum3 And ynum3 > 0 Then
num5.Text = xnum3
num6.Text = ynum3
xDegree = ((Math.Atan(ynum3 / xnum3)) * (180 / Math.PI))
degree = Math.Round(xDegree, 2)
xEuler = Math.Sqrt((xnum3 ^ 2) + (ynum3 ^ 2))
Eulertemp = Math.Round(xEuler, 2)
Me.Euler3.Text = Eulertemp & " e " & degree & ""
Me.Standard3.Text = Eulertemp & " ([ cos " & degree & " )] + [( isin " & degree & " )]"
Me.Polar3.Text = Eulertemp & "" & degree & ""
MsgBox("you got it!")
Else
Me.Euler3.Text = "Error! Invalid Input , number only"
Me.Standard3.Text = "Error! Invalid Input , number only"
Me.Polar3.Text = "Error! Invalid Input , number only"
MsgBox("Please Enter a Valid Input, 'A Number'", MsgBoxStyle.Exclamation, "ERROR!
ERROR! ERROR! ERROR! ERROR! ERROR!")
End If
End Sub
End Class

OUTPUT:

WHEN YOU INPUT OTHER


CHARACTERS, AN ERROR BOX
APPEARS:

Anda mungkin juga menyukai