I have this chart i'm testing my results against.
Are these even correct values? Any pointers where i'm going wrong?
Code:Private Sub calculate() Select Case ComboBox1.SelectedIndex Case 0 ' sine(sin) Label3.Text = $"Math.Sin({NumericUpDown1.Value} * Math.PI / 180)" Label4.Text = round(sine(toRadians(NumericUpDown1.Value))) Case 1 ' cosine(cos) Label3.Text = $"Math.Cos({NumericUpDown1.Value} * Math.PI / 180)" Label4.Text = round(cosine(toRadians(NumericUpDown1.Value))) Case 2 ' tangent(tan) Label3.Text = $"Math.Tan({NumericUpDown1.Value} * Math.PI / 180)" Label4.Text = round(tangent(toRadians(NumericUpDown1.Value))) Case 3 ' cotangent(cot) Label3.Text = $"1 / Math.Tan({NumericUpDown1.Value} * Math.PI / 180)" Label4.Text = round(cotangent(toRadians(NumericUpDown1.Value))) Case 4 ' secant(sec) Label3.Text = $"1 / Math.Cos({NumericUpDown1.Value} * Math.PI / 180)" Label4.Text = round(secant(toRadians(NumericUpDown1.Value))) Case 5 ' cosecant(csc) Label3.Text = $"1 / Math.Sin({NumericUpDown1.Value} * Math.PI / 180)" Label4.Text = round(cosecant(toRadians(NumericUpDown1.Value))) Case Else ' -1 Label3.Text = "" Label4.Text = "" End Select End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load NumericUpDown1.Maximum = Decimal.MaxValue NumericUpDown2.Maximum = Integer.MaxValue End Sub Private Function sine(radians As Double) As Double Return Math.Sin(radians) End Function Private Function cosine(radians As Double) As Double Return Math.Cos(radians) End Function Private Function tangent(radians As Double) As Double Return Math.Tan(radians) End Function Private Function cotangent(radians As Double) As Double Dim t As Double = tangent(radians) Return 1 / t End Function Private Function secant(radians As Double) As Double Dim c As Double = cosine(radians) Return 1 / c End Function Private Function cosecant(radians As Double) As Double Dim s As Double = sine(radians) Return 1 / s End Function Private Function toRadians(d As Decimal) As Double Return d * Math.PI / 180 End Function Private Function round(d As Double) As String If Double.IsNegativeInfinity(d) Or Double.IsPositiveInfinity(d) Then Return "Infinity" Return d.ToString End Function




Reply With Quote