Grupo
UNIVERSIDAD NACIONAL DE SAN AGUSTÍN
              FACULTAD DE PRODUCCIÓN Y SERVICIOS
         ESCUELA                                   PROFESIONAL DE
                         INGENIERÍA INDUSTRIAL
                                 Curso:
                    Programación y métodos numéricos
                                Docente:
                       Ing. Juna Carlos Torre Blanca
                                 Grupo:
                                    C
                                Alumnos:
       Monterola Mamani Ángel Martin
       Quintanilla Córdova Hugo
       Torres Mora Maritza
        Larico Obregon Harold Vichenzo
       Condori Huanqui Diego
                              Arequipa-Perú
                                  2016
                Menu de Integrales y Raices
Module Module1
    Dim opc, a, b, X As Single
    Sub menuprincipal(ByRef opc As Integer)
        Console.ForegroundColor = ConsoleColor.Yellow
        Console.SetCursorPosition(25, 1)
        Console.Write("***MENÚ DE INTEGRALES Y RAÍCES***")
        Console.SetCursorPosition(27, 2)
        Console.Write("_____________________________")
        Console.SetCursorPosition(4, 3)
        Console.Write("1.- Integrales")
        Console.SetCursorPosition(4, 4)
        Console.Write("2.- Raices de ecuaciones")
        Console.SetCursorPosition(4, 5)
        Console.Write("3.- Fin")
        Console.SetCursorPosition(4, 6)
        Console.Write("Elegir opciòn--->")
        opc = Console.ReadLine
    End Sub
    Function menu1(ByRef opc As Integer)
        Console.Clear()
        Console.SetCursorPosition(20, 1)
        Console.Write(" ***MENU DE INTEGRALES*** ")
        Console.SetCursorPosition(24, 2)
        Console.Write("_________________")
        Console.SetCursorPosition(1, 3)
        Console.Write("1 Integral Circunscrita")
        Console.SetCursorPosition(1, 4)
        Console.Write("2 Integral Inscrita ")
        Console.SetCursorPosition(1, 5)
        Console.Write("3 Integral Punto Medio")
        Console.SetCursorPosition(1, 6)
        Console.Write("4 Integral Trapecial ")
        Console.SetCursorPosition(1, 7)
        Console.Write("5 Volver al menù principal ")
        Console.SetCursorPosition(1, 8)
        Console.Write("Escoja la opcion a trabaja--->")
        opc = Console.ReadLine
        Return opc
    End Function
    Sub menuintegrales()
        Console.Clear()
        Do
            Dim a, b, nd, I, opc As Single
            opc = menu1(opc)
            If opc = 1 Then
                datos(a, b, nd)
                I = circunscrita(a, b, nd)
            ElseIf opc = 2 Then
                datos(a, b, nd)
               I = inscrita(a, b, nd)
           ElseIf opc = 3 Then
               datos(a, b, nd)
               I = punto_medio(a, b, nd)
           ElseIf opc = 4 Then
               datos(a, b, nd)
               I = trapecial(a, b, nd)
           ElseIf opc = 5 Or opc > 5 Then
               Exit Do
           End If
           Console.Write("La integral es: {0}", I)
           Console.ReadLine()
    Loop
End Sub
Function datos(ByRef a As    Single, ByRef b As Single, ByRef nd As Single)
    Console.Clear()
    Console.Write("Escoja    el primer limite de integración--->")
    a = Console.ReadLine
    Console.Write("Escoja    el segundo limite de integración---> ")
    b = Console.ReadLine
    Console.Write("Escoja    el numero de diviciones--->")
    nd = Console.ReadLine
    Return a And b And nd
End Function
Function circunscrita(ByVal a As Single, b As Single, nd As Single)
    Console.Clear()
    Dim x, f, an, ar, I As Single
    I = 0
    an = (b - a) / nd
    For x = (a + an) To b Step an
         f = x * x
         ar = f * an
         I = I + ar
    Next
    Return I
End Function
Function inscrita(ByVal a As Single, b As Single, nd As Single)
    Console.Clear()
    Dim x, f, an, ar, I As Single
    I = 0
    an = (b - a) / nd
    For x = a To (b - an) Step an
         f = x * x
         ar = f * an
         I = I + ar
    Next
    Return I
End Function
Function punto_medio(ByVal a As Single, b As Single, nd As Single)
    Console.Clear()
    Dim x, f, an, ar, I As Single
    I = 0
    an = (b - a) / nd
    For x = (a + an / 2) To b Step an
         f = x * x
                 ar = f * an
                 I = I + ar
          Next
          Return I
      End Function
      Function trapecial(ByVal a As Single, b As Single, nd As Single)
          Console.Clear()
          Dim x, f, an, ar, I, g As Single
          I = 0
          an = (b - a) / nd
          For x = a To (b - an) Step an
               f = x * x
               g = (x + an) * (x + an)
               ar = ((f + g) / 2) * an
               I = I + ar
          Next
          Return I
      End Function
      Sub MENURAICES(ByRef opc As Integer)
          Console.Clear()
          Console.SetCursorPosition(25, 1)
          Console.WriteLine("***MENU DE RAICES***")
          Console.SetCursorPosition(27, 2)
          Console.Write("_________________")
          Console.SetCursorPosition(4, 3)
          Console.WriteLine("1.- Busca")
          Console.SetCursorPosition(4, 4)
          Console.WriteLine("2.- Biseccion")
          Console.SetCursorPosition(4, 5)
          Console.WriteLine("3.- Regula")
          Console.SetCursorPosition(4, 6)
          Console.WriteLine("4.- Ir al menu principal")
          Console.SetCursorPosition(4, 7)
          Console.Write("ESCOGER UNA OPCION--->")
          opc = Console.ReadLine
      End Sub
      Sub menu2()
          Do
              MENURAICES(opc)
              busca(a, b)
              If opc = 1 Then
                  Console.Clear()
                  Console.WriteLine("LOS INTERVALOS SON:[{0},{1}]", a, b)
              ElseIf opc = 2 Then
                  Console.Clear()
                  Console.WriteLine("El punto de interseccion es: {0} ", biseccion(a,
b))
                 ElseIf opc = 3 Then
                     Console.Clear()
                     Console.WriteLine("El punto de interseccion es:   {0} ", RF(a, b))
                 ElseIf opc = 4 Then
                     Exit Do
                 End If
                 Console.ReadLine()
          Loop
      End Sub
Function Fun(ByVal x As Single) As Single
    Return (x * x + 2 * x - 4)
End Function
Sub busca(ByRef a As Single, ByRef b As Single)
    Dim x As Single
    x = 0
    While fun(x) < 0
        x = x + 0.1
    End While
    a = x
    b = x + 0.1
End Sub
Function BISECCION(ByVal a As Single, ByVal b As Single) As Single
    Dim c As Single
    While (b - a) > 0.00001
        c = (a + b) / 2
        If (Fun(a) * Fun(c) > 0) Then
             a = c
        Else
             b = c
        End If
    End While
    Return (c)
End Function
Function RF(ByVal a As Single, ByVal b As Single) As Single
    Dim c As Single
    Dim d As Single = 10
    While (d > 0.001)
        c = (a * Fun(b) - b * Fun(a)) / (Fun(b) - Fun(a))
        If (Fun(a) * Fun(c) > 0) Then
             d = c - a
             a = c
        Else
             d = b - c
             b = c
        End If
    End While
    Return c
End Function
Sub Main()
    Do
         Console.Clear()
         menuprincipal(opc)
         Select Case (opc)
             Case 1
                 Console.Clear()
                 menuintegrales()
             Case 2
                 Console.Clear()
                 menu2()
             Case 3
                 End
         End Select
         Console.ReadLine()
    Loop
    End Sub
End Module