proyecto blob

Download Proyecto Blob

Post on 07-Jul-2015

516 views

Category:

Technology

2 download

Embed Size (px)

TRANSCRIPT

  • 1. ING: Patricio Quiroz

2. EJERCICIOS GAMBAS (BAJO CONSOLA) EJERCICIO 1 HOLA MUNDOPUBLIC SUB Main() PRINT "HOLA MUNDOn" PRINT "HOLA MUNDO" ENDEJERCICIO 2 SUMA `Mi primera suma PUBLIC SUB Main() DIM A AS Integer DIM B AS Integer DIM S AS Integer A = 10 B = 20 S=A+B PRINT "LA SUMA ES...:" PRINT S END 3. EJERCICIO 3 MAYOR DE 3 entre 3 nmeros averiguar cul es el mayor el menor y el intermedio.PUBLIC SUB Main()DIM A, B, C AS Integer A= 6 B = 10 C = 80IF A > B AND A > C THEN PRINT "MAYOR ES..: " & A IF C > B THEN PRINT "INTERMEDIO ES..: " & C PRINT "MENOR ES..: " & B ELSE PRINT "INTERMEDIO ES..: " & B PRINT "MENOR ES..: " & C ENDIFELSE IF B > C THEN PRINT "MAYOR ES..: " & BIF A > C THEN PRINT "INTERMEDIO ES..: " & A PRINT "MENOR ES..: " & C ELSE PRINT "INTERMEDIO ES..: " & C 4. PRINT "MENOR ES..: " & A ENDIFELSE PRINT "MAYOR ES..: " & C IF A > B THEN PRINT "INTERMEDIO ES..: " & A PRINT "MENOR ES..: " & B ELSE PRINT "INTERMEDIO ES..: " & B PRINT "MENOR ES..: " & A ENDIF ENDIF ENDIFEND 5. EJERCICIO 4DIGITO AUTOVERIFICADORPUBLIC SUB Main() DIM B, C, D, E, F, G, H, I, J, K, W AS Integer DIM A AS String PRINT "INGRESE EL NUMERO DE CEDULA" INPUT AFOR B = 1 TO 9 STEP 1 C = Str(Mid(A, B, 1)) D = B MOD 2IF D = 0 THEN I=I+C ELSE H=C*2IF H > 9 THEN D = H MOD 10 E = Int(h / 10) F=D+E ELSE F=H ENDIF G=G+F ENDIFNEXT J=G+I K = J MOD 10 W = 10 - K PRINT "EL NUMERO VERIFICADOR DE LA CEDULA ES : " PRINT W END 6. EJERCICIO 5 DE TODO UN POCOPUBLIC SUB Main() DIM a AS Integer DIM NOMBRE, C AS String DIM F, I, X, T AS Integer PRINT "INGRESE UN NMERO..:" INPUT a PRINT "INGRESE UN NOMBRE..:" INPUT NOMBRE PRINT "EL NMERO QUE INGRESE ES..", a PRINT "EL NOMBRE ES..", NOMBRE C = Mid(NOMBRE, 2, 2) PRINT "EL CARACTER SELECCIONADO ES..:", C F=1 FOR I = 1 TO 5 F=F*I NEXT PRINT "EL FACTORIAL DE 5 ES..: ", F X=1 WHILE X 0 x1 = valor MOD 2 x2 = Int(valor / 2) cadena = cadena & Str(x1) valor = x2WENDFOR i = Len(cadena) TO 1 STEP -1 cadena2 = cadena2 & (Mid(cadena, i, 1))NEXTvisor.text = cadena2 END PUBLIC SUB Button22_Click()DIM valor, x1, x2, i AS IntegerDIM cadena, cadena2 AS Stringvalor = visor.TextWHILE valor > 0 x1 = valor MOD 8 22. x2 = Int(valor / 8) cadena = cadena & Str(x1) valor = x2WENDFOR i = Len(cadena) TO 1 STEP -1 cadena2 = cadena2 & (Mid(cadena, i, 1))NEXTvisor.text = cadena2 END PUBLIC SUB Button23_Click()DIM valor, x1, x2, i AS IntegerDIM cadena, cadena2 AS Stringvalor = visor.Text WHILE valor > 0 x1 = valor MOD 16 x2 = Int(valor / 16) IF x1 = 10 THEN cadena = cadena & "A" ELSE IF x1 = 11 THEN cadena = cadena & "B" ELSE IF x1 = 12 THEN cadena = cadena & "C" ELSE IF x1 = 13 THEN cadena = cadena & "D" ELSE IF x1 = 14 THEN cadena = cadena & "E" ELSE IF x1 = 15 THEN cadena = cadena & "F" ELSE cadena = cadena & Str(x1)ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF valor = x2WENDFOR i = Len(cadena) TO 1 STEP -1 cadena2 = cadena2 & (Mid(cadena, i, 1)) NEXTvisor.Text = cadena2 END PUBLIC SUB Button24_Click()BAN = 7IF visor.text 0 THENOP1 = visor.TextELSEOP1 = 0ENDIFvisor.text = OP1 END PUBLIC SUB Button27_Click() BAN = 8IF visor.text 0 THENOP1 = visor.TextELSEOP1 = 0 23. ENDIFvisor.Clear END PUBLIC SUB Button25_Click()BAN = 9IF visor.text 0 THEN OP1 = visor.TextELSE OP1 = 0ENDIFvisor.text = OP1 END PUBLIC SUB Button26_Click()DIM a, b AS LongDIM valor AS Integervalor = visor.Textb=1FOR a = valor TO 1 STEP -1b=b*aNEXTvisor.Text = b END PUBLIC SUB Button28_Click()DIM r AS Floatr = Rad(visor.text)visor.text = Sin(r) END PUBLIC SUB Button29_Click() DIM r AS Float r = Rad(visor.text) visor.text = Cos(r) END PUBLIC SUB Button30_Click()DIM r AS Floatr = Rad(visor.text)visor.text = Tan(r) END EJERCICIO 20 CONVIERTE NMERO A LETRAS PUBLIC FUNCTION EnLetras(numero AS String) AS String DIM b, paso AS Integer DIM expresion, entero, deci, flag AS String flag = "N" FOR paso = 1 TO Len(numero)IF Mid(numero, paso, 1) = "." THENflag = "S"ELSEIF flag = "N" THEN entero = entero & Mid(numero, paso, 1)ELSE deci = deci & Mid(numero, paso, 1)END IFEND IF NEXTIF Len(deci) = 1 THENdeci = deci & "0" END IF flag = "N" IF Val(numero) >= -999999999 AND Val(numero) "5" THEN flag = "N" expresion = expresion & "dieci"END IF CASE "2"IF Mid(entero, b + 1, 1) = "0" THEN expresion = expresion & "veinte " 25. flag = "S" ELSE expresion = expresion & "veinti" flag = "N" END IFCASE "3"IF Mid(entero, b + 1, 1) = "0" THENexpresion = expresion & "treinta "flag = "S"ELSEexpresion = expresion & "treinta y "flag = "N"END IFCASE "4"IF Mid(entero, b + 1, 1) = "0" THENexpresion = expresion & "cuarenta "flag = "S"ELSEexpresion = expresion & "cuarenta y "flag = "N"END IFCASE "5"IF Mid(entero, b + 1, 1) = "0" THENexpresion = expresion & "cincuenta "flag = "S"ELSEexpresion = expresion & "cincuenta y "flag = "N"END IFCASE "6"IF Mid(entero, b + 1, 1) = "0" THENexpresion = expresion & "sesenta "flag = "S"ELSEexpresion = expresion & "sesenta y "flag = "N"END IFCASE "7"IF Mid(entero, b + 1, 1) = "0" THENexpresion = expresion & "setenta "flag = "S"ELSEexpresion = expresion & "setenta y "flag = "N"END IFCASE "8"IF Mid(entero, b + 1, 1) = "0" THENexpresion = expresion & "ochenta "flag = "S"ELSEexpresion = expresion & "ochenta y "flag = "N"END IFCASE "9"IF Mid(entero, b + 1, 1) = "0" THENexpresion = expresion & "noventa " 26. flag = "S" ELSE expresion = expresion & "noventa y " flag = "N" END IFEND SELECTCASE 1, 4, 7 SELECT CASE Mid(entero, b, 1)CASE "1"IF flag = "N" THEN IF paso = 1 THENexpresion = expresion & "uno " ELSEexpresion = expresion & "un " END IFEND IFCASE "2"IF flag = "N" THEN expresion = expresion & "dos "END IFCASE "3"IF flag = "N" THEN expresion = expresion & "tres "END IFCASE "4"IF flag = "N" THEN expresion = expresion & "cuatro "END IFCASE "5"IF flag = "N" THEN expresion = expresion & "cinco "END IFCASE "6"IF flag = "N" THEN expresion = expresion & "seis "END IFCASE "7"IF flag = "N" THEN expresion = expresion & "siete "END IFCASE "8"IF flag = "N" THEN expresion = expresion & "ocho "END IFCASE "9"IF flag = "N" THEN expresion = expresion & "nueve "END IF END SELECT END SELECT IF paso = 4 THEN IF Mid(entero, 6, 1) "0" OR Mid(entero, 5, 1) "0" OR Mid(entero, 4, 1) "0" OR (Mid(entero, 6, 1) = "0" AND Mid(entero, 5, 1) = "0" AND Mid(entero, 4, 1) = "0" AND Len(entero)