Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
mqwertyu iopasdfghjklzxcvbnmqwertyuiopasdfg
COMPUTACION II
DIAGRAMA DE FLUJO.
INICIO
base, altura
Area=(base*altura)/2
Area
FIN
EJERCICIO:Pseudocgido y diagrama de flujo. 1. Calcular el volumen de una esfera. 2. Calcular la superficie y volumen de un cilindro.
COMPUTACION II
SOLUCIN
PSEDOCODIGO
/*inicio*/ /*declaracin de variables */ Radio, volumen: real /*lectura de datos */ Leer(radio) /*calculo del volumen */ volumen=(4/3)*3.14*(radio**3) DIAGRAMA DE FLUJO. INICIO
radio
volumen=(4/3)*3.1416*(radio**3)
volumen
FIN
COMPUTACION II SOLUCIN 2: /*inicio*/ /*declaracin de variables */ Radio, volumen: real /*lectura de datos */ Leer(radio) /*calculo del volumen */
altura, radio
superficie=2*3.1416*radio*(altura+radio) volumen=3.1416*(radio**2)*altura
superficie volumen
FIN
COMPUTACION II
3. Se ingresa tres nmeros enteros obtener el mayor de los nmeros enviando un mensaje respectivo.
INICIO
A,B: enteros
A,B
son iguales
B es mayor
FIN
1. El volumen de un cilindro.
Private Sub Command1_Click() Dim valor1 As Double R = caja1.Text H = caja2.Text valor1 = 3.1415 * (R ^ 2) * H caja3.Text = valor1 End Sub Private Sub Command2_Click() End End Sub Private Sub Command3_Click() caja1.Text = "" caja2.Text = "" caja3.Text = "" End Sub 2. La superficie y volumen de un cubo.
PSEUDOCDIGO. /*Inicio*/ /*Declaracin de variables*/ R,H, valor1 /*Lectura de datos */ R,H /*Calculo de volumen */ Valor1 /*Visualizacin o impresin de volumen/ /*Fin*/
COMPUTACION II
Private Sub Command1_Click() rad = Text1.Text sup = (rad ^ 2) * 6 vol = rad ^ 3 Text2.Text = sup Text3.Text = vol End Sub
Private Sub Command1_Click() Dim valor1, valor2 As Double valor1 = 4 * 3.1415 * (caja1.Text ^ 2) valor2 = (4 * 3.1415 * (caja1.Text ^ 3)) / 3 caja2.Text = valor1 caja3.Text = valor2 End Sub Private Sub Command2_Click() End End Sub Private Sub Command3_Click() caja1.Text = "" caja2.Text = "" caja3.Text = "" End Sub
PSEUDOCDIGO. /*Inicio*/ /*Declaracin de variables*/ rad,volumen, superficie /*Lectura de datos */ radio /*Calculo de superficie, volumen*/ /*Visualizacin o impresin de superficie, volumen*/ /*Fin*/
COMPUTACION II
Private Sub Text1_KeyPress(KeyAscii As Integer) Dim n As Double If KeyAscii = 13 Then n = Val(Text1.Text) If n Mod 2 = 0 Then MsgBox "El nmero es par" Else MsgBox "El nmeor es impar" End If End If End Sub
INICIO
n/2=0 F V
El nmero es impar
El nmero es par
FIN
COMPUTACION II
Private Sub caja1_KeyPress(KeyAscii As Integer) Dim valor1 As Double If (KeyAscii = 13) Then valor1 = Val((5 * (caja1.Text - 32)) / 9) caja2.Text = valor1 End If End Sub Private Sub caja2_KeyPress(KeyAscii As Integer) Dim valor1 As Double If (KeyAscii = 13) Then valor2 = Val((9 * caja1.Text / 5) + 32) caja1.Text = valor1 End If End Sub
INICIO
Fah, Cent
Fah, Cent
Cent Fah
FIN
COMPUTACION II
INICIO
Hor,Min,Seg
Hor,Min,Seg
Hor=min/60 Seg=min*60
Hor=seg/3600 Min=seg/60
FIN
COMPUTACION II
Private Sub caja1_KeyPress(KeyAscii As Integer) Dim valor1, valor2 As Double If (KeyAscii = 13) Then valor1 = Val(caja1.Text) * 60 valor2 = Val(caja1.Text) * 3600 caja2.Text = valor1 caja3.Text = valor2 End If End Sub Private Sub caja2_KeyPress(KeyAscii As Integer) Dim valor1, valor2 As Double If (KeyAscii = 13) Then valor1 = Val(caja2.Text) / 60 valor2 = Val(caja2.Text) * 60 caja1.Text = valor1 caja3.Text = valor2 End If End Sub Private Sub caja3_KeyPress(KeyAscii As Integer) Dim valor1, valor2 As Double If (KeyAscii = 13) Then valor1 = Val(caja3.Text) / 3600 valor2 = Val(caja3.Text) / 60 caja1.Text = valor1 caja2.Text = valor2 End If End Sub Private Sub Command1_Click() caja1.Text = "" caja2.Text = "" caja3.Text = "" End Sub Private Sub sakuda_Click() End End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) Dim valor1 As Double If (KeyAscii = 13) Then valor1 = Val(caja3.Text) / 3600 caja1.Text = Format$(valor1)
COMPUTACION II Else
Dim valor2 As Double If (KeyAscii = 13) Then valor2 = Val(caja3.Text / 60) caja2.Text = Format$(valor2) End If End Sub 7. Se ingresa la edad de un persona, enviar un mensaje si la persona es mayor de edad.
INICIO
edad Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If Text1.Text < 18 Then MsgBox "Es menor de edad" Else MsgBox "Es mayor de edad" End If End If End Sub v
edad
edad<18 F
Es menor de edad
Es mayor de edad
FIN
COMPUTACION II
8. Se ingresa un nmero entero mayor que cero y verificar si es par o impar 9. Ingresar tres nmeros reales y obtener el nmero mayor.
Private Sub Command1_Click() Dim a, b, c As Integer a = Val(Text1.Text) b = Val(Text2.Text) c = Val(Text3.Text) If a > b And a > c Then Text4.Text = Val(a) End If If b > a And b > c Then Text4.Text = Val(b) End If If c > b And c > a Then Text4.Text = Val(c) End If End Sub .c>a y c>b .b>c y b>a
a,b,c
c es mayor
FIN
COMPUTACION II
Private Sub Command1_Click() Dim a, b, c As Integer a = Val(Text1.Text) b = Val(Text2.Text) c = Val(Text3.Text) If a < b And a < c Then Text4.Text = Val(a) End If If b < a And b < c Then Text4.Text = Val(b) End If If c < b And c< a Then Text4.Text = Val(c) End If End Sub .c< a y c< b .b< c y b< a
a,b,c
c es menor
FIN
COMPUTACION II
Private Sub Command1_Click() Dim num1, num2 As Integer a = caja1.Text b = caja2.Text c = caja3.Text If (b ^ 2 - 4 * a * c) >= 0 Then num1 = Round((-b + Sqr(b ^ 2 - 4 * a * c)) / (2 * a), 4) num2 = Round((-b - Sqr(b ^ 2 - 4 * a * c)) / (2 * a), 4) caja4.Text = num1 caja5.Text = num2 Else caja4.Text = (-b / 2 * a) & "+" & (Round(Sqr(-((b ^ 2 - 4 * a * c))) / (2 * a), 4) & "i") caja5.Text = (-b / 2 * a) & "-" & (Round(Sqr(-((b ^ 2 - 4 * a * c))) / (2 * a), 4) & "i") End If End Sub Private Sub Command2_Click() caja1.Text = "" caja2.Text = "" caja3.Text = "" caja4.Text = "" caja5.Text = "" End Sub Private Sub Command3_Click() End End Sub
COMPUTACION II
Private Sub Command1_Click() Dim suma as double Dim n as double A=text1.text Suma =0 N=0 for n=1 to a Suma=Suma+N next N end If Private Sub Command2_Click() caja1.Text = "" caja2.Text = "" End Sub Private Sub Command3_Click() End End Sub
INICIO
Suma=0 N=0
V Suma
FIN
COMPUTACION II
Private Sub Command1_Click() Dim suma as double Dim n as double A=text1.text Suma =0 N=1 for n=1 to a step 2 Suma=Suma+N next N end If Private Sub Command2_Click() caja1.Text = "" caja2.Text = "" End Sub F Private Sub Command3_Click() End End Sub
INICIO
Suma=0 N=1
N=N+1
Suma=Suma+N
V N=A F
Suma
FIN
COMPUTACION II
Private Sub Command1_Click() a = Text1.Text suma = 0 n=0 For n = 0 To a suma = suma + n ^ 2 Next n Text2.Text = suma End Sub Private Sub Command2_Click() caja1.Text = "" caja2.Text = "" End Sub Private Sub Command3_Click() End End Sub F
INICIO
suma=0 n=0
n=n^2
Suma=Suma+n^2
n=a
V Suma
FIN
COMPUTACION II
15. Suma de 1 + 1/2 + 1/3 +1/4 + 1/5 + + 1/n , para un n mayor que1.
Private Sub Command1_Click() Dim n, sum, x As Double n = Text1.Text suma = 1 For x = 2 To n suma = suma + (1 / x) Text2.Text = Round(suma, 4) Next End Sub
INICIO
suma=1 n=0
X=x+1
Suma=Suma+(1/x)
F x=n
V Suma
FIN
COMPUTACION II
Private Sub Command1_Click() Dim Factorial As Double Num = caja1.Text For I = 1 To Num - 1 Num = Num * I Factorial = Num Next caja2.Text = Factorial End Sub Private Sub Command2_Click() caja1.Text = "" caja2.Text = "" End Sub Private Sub Command3_Click() End End Sub
INICIO
.factorial=1 n=1
n=n+1
factorial=factorial*n
F n=Num
V factorial
FIN
COMPUTACION II
17. Calculadora de dos nmeros con las operaciones de suma, resta, divisin y multiplicacin. Private Sub Command1_Click() A = Val(Text5.Text) B = Val(Text1.Text) Text2.Text = A + B End Sub Private Sub Command2_Click() A = Val(Text5.Text) B = Val(Text1.Text) Text2.Text = A - B End Sub Private Sub Command3_Click() A = Val(Text5.Text) B = Val(Text1.Text) Text2.Text = A * B End Sub Private Sub Command4_Click() A = Val(Text5.Text) B = Val(Text1.Text) Text2.Text = A / B End Sub
INICIO
A,B: enteros
A,B
Text2.Text = A + B
Text2.Text = A - B
Text2.text=A*B
Text2.text=A/B
Text2.text
FIN
COMPUTACION II
Private Sub Command1_Click() Dim suma As Double Dim n As Double a = Text1.Text suma = 1 n=0 For n = 1 To a suma = suma + ((-1) ^ (n + 1)) * (1 / n) Next n Text2.Text = suma End Sub
INICIO
suma=1 n=0
n=n+1
suma=suma+((-1) ^ (n + 1)) * (1 / n)
n=a
suma
FIN
COMPUTACION II
Private Sub Command1_Click() Dim potencia As Double b = Text1.Text e = Text2.Text potencia = b ^ e Text3.Text = potencia End Sub
PSEUDOCDIGO. /*Inicio*/ /*Declaracin de variables*/ b,e, potencia: reales /*Lectura de datos */ B,e /*Calculo de potencia */ potencia /*Visualizacin o impresin de potencia/ /*Fin*/