1.
- Menu y sobroutine varios
Cls
While (op <> 5)
Cls
Input "Digitar un numero"; n1
Input "Digitar otro Numero"; n2
Print "Que desea hacer con estos valores"
Print "1)Sumar"
Print "2)restar"
Print "3)Multiplicar"
Print "4)Dividir"
Print "5)Salir"
Input "Diigitar una opcion:"; op
Select Case op
Case 1
Call suma(n1, n2, s)
Case 2
Call resta(n1, n2, s)
Case 3
Call multi(n1, n2, s)
Case 4
Call divi(n1, n2, s)
Case 5
End Select
Wend
Print "Fin del Programa"
End
Sub suma (a As Integer, b As Integer, s As Integer)
s = a + b
Print "La suma es igual a:"; s
Input "Presione enter para volver"; e$
End Sub
Sub resta (a As Integer, b As Integer, s As Integer)
s = a - b
Print "La resta es igual a:"; s
Input "Presione enter para volver"; e$
End Sub
Sub multi (a As Integer, b As Integer, s As Integer)
s = a * b
Print "La multiplicacion es igual a:"; s
Input "Presione enter para volver"; e$
End Sub
Sub divi (a As Integer, b As Integer, s As Integer)
s = a / b
Print "La division es igual a:"; s
input"Presione enter para volver";e$
End Sub
2.-Menu y sobroutine convencion numerica
Cls
While (op <> 3)
Cls
Print "Programa de conversiones"
Print "1)Convertir a Binario"
Print "2)Convertir a octal"
Print "5)Salir"
Input "Digitar un valor decimal:"; n1
Input "Diigitar una opcion:"; op
Select Case op
Case 1
Call bin(n1)
Case 2
Call octa(n1)
Case 3
Case Else
Print "Opcion Invalida"
End Select
Wend
Print "Fin del Programa"
End
Sub bin (decimal As Integer)
binario$ = " "
Do While decimal > 0
resto = decimal Mod 2
binario$ = Str$(resto) + binario$
decimal = decimal \ 2
Loop
Print "El numero binario equivalente es: "; binario$
Input "Presione enter para volver"; e$
End Sub
Sub octa (decimal As Integer)
octal$ = " "
Do While decimal > 0
resto = decimal Mod 8
octal$ = Str$(resto) + octal$
decimal = decimal \ 8
Loop
Print "El numero octqal equivalente es: "; octal$
Input "Presione enter para continuar"; e$
End Sub
3.- Menu y sobroutine multiplos y numeros primos
Cls
Dim Shared num1, num2, nprimo, i, j As Integer
Screen 12
While (op <> 3)
Cls
Input "Ingrese el numero inicial:"; num1
Input "Ingrese el numero: final"; num2
Input "Que valor desea saber los multiplos"; va
Print "Que desea hacer con estos valores"
Print "1)ver los multiplos"
Print "2)ver los numeros primos"
Print "3)Salir"
Input "Diigitar una opcion:"; op
Select Case op
Case 1
Call multi(num1, num2, va)
Case 2
Call pri(num1, num2)
Case 3
End Select
Wend
Print "Fin del Programa"
End
Sub multi (a As Integer, b As Integer, s As Integer)
If a > b Then
Print "Primer numero debe ser menor que el 2do"
Else
Print "Los multiplos de"; s; " entre "; a; "y "; b; " son:"
For i = a To b
If (i Mod s) = 0 Then
Print i
End If
Next i
End If
Input "Presione enter para volver"; e$
End Sub
Sub pri (num1 As Integer, num2 As Integer)
' DIM i AS INTEGER, j AS INTEGER, es_primo AS BOOLEAN
'Print "DEPURANDO EL CODIGO"
Print
Print "Rango de N_Primos desde el numero inicial:"; num1; "al
numero final:"; num2
Print
For i = num1 To num2
nprimo = -1
For j = 2 To Sqr(i)
If i Mod j = 0 Then
nprimo = FALSE
Exit For
End If
Next j
If nprimo And i > 1 Then
Print i;
End If
Next i
Print
Input "Presione enter para volver"; e$
End Sub
4.-sobroutine archivos de indiceacademico
Cls
While (op <> 2)
Cls
Input "Cuantas asignaturas tomo este semestre"; c2
Print "Que desea hacer calcular"
Print "1)Indice"
Print "2)Salir"
Input "Diigitar una opcion:"; op
Select Case op
Case 1
Call indice(c2)
Case 2
End Select
Wend
Print "Fin del Programa"
End
Sub indice (c2)
Dim n(c2), cr(c2), cla$(c2)
scr = 0
sn = 0
Input "Nombre del estudiante"; Nom$
Input "Matricula del estudiante"; mat$
For j = 1 To c2
Print "Asinatura no:"; j
Input "Digitar nota:"; n(j)
Input "Digitar creditos"; cr(j)
Input "Digitar clave:"; cla$(j)
sn = sn + (n(j) * cr(j))
scr = scr + cr(j)
ind = sn / scr
Next j
Print "Reporte por estudiante"
Print "Nombre:"; Nom$; " Matricula:"; mat$
Print "ASIGNATURA "; "CREDITOS "; " NOTAS"
For j = 1 To c2
Print ; cla$(j); " "; cr(j); " "; n(j)
Next j
Print "___________________________________________________"
Print "Indice del estudiante es igual a:"; ind
Print "___________________________________________________"
Input "Presione enter para volver"; e$
End Sub