Navigace: Hlavní stránka -> BASIC -> 08 Knihovny ->08.02 Goniometrické funkce

MENU

08.02 Goniometrické funkce

Zadání:
Sestavte knihovnu, která bude obsahovat goniometrické funkce nedefinované v jazyce Basic. Tuto knihovnu použijte ve vlastním programu.
Public Class Class1

    Public Shared Function cotg(ByVal x As Double) As Double
        cotg = Math.Cos(x) / Math.Sin(x)
    End Function

    Public Shared Function arcsin(ByVal x As Double) As Double
        arcsin = Math.Atan(x / Math.Sqrt(1 - x ^ 2))
    End Function

    Public Shared Function arccos(ByVal x As Double) As Double
        arccos = Math.PI / 2 - arcsin(x)
    End Function

    Public Shared Function arccotan(ByVal x As Double) As Double
        arccotan = Math.PI / 2 - Math.Atan(x)
    End Function

End Class
Module Module1

    Sub Main()

        Dim x, y As Double
        Dim z As Char

        Console.Write("Zadejte hodnotu: ")
        x = Console.ReadLine
        Console.WriteLine("-----------------------------------")
        Console.WriteLine("1 sinus")
        Console.WriteLine("2 cosinus")
        Console.WriteLine("3 tangens")
        Console.WriteLine("4 cotangens")
        Console.WriteLine("5 arcussinus")
        Console.WriteLine("6 arcuscosinus")
        Console.WriteLine("7 arcustangens")
        Console.WriteLine("8 arcuscotangens")
        Console.WriteLine("-----------------------------------")

        Console.Write("Zadejte funkci: ")
        y = Console.ReadLine

        Select Case y
            Case "1"
                y = Math.Sin(x)
                Console.WriteLine("sin({0:0.000})={1:0.000}", x, y)
            Case "2"
                y = Math.Cos(x)
                Console.WriteLine("cos({0:0.000})={1:0.000}", x, y)
            Case "3"
                y = Math.Tan(x)
                Console.WriteLine("tg({0:0.000})={1:0.000}", x, y)
            Case "4"
                y = ClassLibrary1.Class1.cotg(x)
                Console.WriteLine("cotg({0:0.000})={1:0.000}", x, y)
            Case "5"
                y = ClassLibrary1.Class1.arcsin(x)
                Console.WriteLine("arcsin({0:0.000})={1:0.000}", x, y)
            Case "6"
                y = ClassLibrary1.Class1.arccos(x)
                Console.WriteLine("arccos({0:0.000})={1:0.000}", x, y)
            Case "7"
                y = Math.Atan(x)
                Console.WriteLine("arctg({0:0.000})={1:0.000}", x, y)
            Case "8"
                y = ClassLibrary1.Class1.arccotan(x)
                Console.WriteLine("arccotg({0:0.000})={1:0.000}", x, y)
            Case Else
                Console.WriteLine("Neznama funkce")
        End Select

        Console.ReadLine()

    End Sub

End Module
program ke stažení