Sei sulla pagina 1di 33

Ejercicios del Primer

Parcial En VB2008
Por Manuel Fernndez y Lisbeth Pacheco
Ejercicios resueltos en el primer parcial traducidos al Visual
Basic 2008, se incluyen anlisis y algoritmos en Algor. El
proceso de toma de datos es a travs de proceso interactivo.

Perodo 2-2009

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009

Contenido
Ejercicio 1 ......................................................................................................................................................3
Anlisis del Problema .................................................................................................................. 3
Tabla de Variables ....................................................................................................................... 3
Algoritmo..................................................................................................................................... 4
Cdigo en Visual Basic 2008 ........................................................................................................ 5
Ejercicio 2 ......................................................................................................................................................7
Anlisis del Problema .................................................................................................................. 7
Tabla de Variables ....................................................................................................................... 7
Algoritmo..................................................................................................................................... 8
Cdigo en Visual Basic 2008 ........................................................................................................ 9
Ejercicio 3 ....................................................................................................................................................10
Anlisis del Problema ................................................................................................................ 10
Tabla de Variables ..................................................................................................................... 10
Algoritmo................................................................................................................................... 11
Cdigo en Visual Basic 2008 ...................................................................................................... 11
Ejercicio 4 ....................................................................................................................................................12
Anlisis del Problema ................................................................................................................ 13
Tabla de Variables ..................................................................................................................... 13
Algoritmo................................................................................................................................... 14
Cdigo en Visual Basic 2008 ...................................................................................................... 15
Ejercicio 5 ....................................................................................................................................................16
Anlisis del Problema ................................................................................................................ 16
Tabla de Variables ..................................................................................................................... 17
Algoritmo................................................................................................................................... 17
Cdigo en Visual Basic 2008 ...................................................................................................... 19
Ejercicio 6 ....................................................................................................................................................20
Anlisis del Problema ................................................................................................................ 21
Tabla de Variables ..................................................................................................................... 21

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009

Algoritmo................................................................................................................................... 22
Cdigo en Visual Basic 2008 ...................................................................................................... 23
Ejercicio 7 ....................................................................................................................................................25
Anlisis del Problema ................................................................................................................ 26
Tabla de Variables ..................................................................................................................... 26
Algoritmo................................................................................................................................... 27
Cdigo en Visual Basic 2008 ...................................................................................................... 28
Ejercicio 8 ....................................................................................................................................................30
Algoritmo................................................................................................................................... 30
Cdigo en Visual Basic 2008 ...................................................................................................... 31

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009

Ejercicio 1

1)
2)
3)
4)

Anlisis del Problema


!
"

"
$

#
" )

%"&
'

+
%(

!
%
$ ,

#
' ,

.
-

/ ,

0 )

% "&
"
%(

*
.

Tabla de Variables

!6 %

"

2
2
2

3
3
23
23

2 ,4
2 ,4
2 ,4
2 ,4

2
2

3
23

2 ,4
2 ,4

2
2

23

2 ,4

3
23
3

2 ,4
2 ,4
2 ,4

2
2
2

#(
#(
%"&

" 6 %"&
78 & 6

7# (

%(

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009

Algoritmo

"#

$%

&'
&

"

)&
+&
#

#$ & '
#

*
*
(

$
$,$-

"$

)&!
+&!
# &'

#$
(
$% 0$1-23

$.+/
0 .23

#$ & '

$,$-

4
%

) 1" 2
+ 1" 2
) 1" 2
+ 1" 2
# 1" )
'
4
7
4
7
$

$&6

&6

).2
#$ 1" $
) 1" )

$
$ $.#$
) 1" ) 8 )
9
9 $
$ $$
+.2
#$ 1"$
+ 1" )
9
9
$ $.+/
+ 1" + 8 )
9 $
$ 0$ 1- 23
0 . 23
# 1" # / $
9 $
4
6:
# 0$; 3 &6
7
<
0
. 6$63 =' 0
. 6 63
4
6
(
>
$
+.2

$&6% )

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009
4

6!

4
9 $
4
4

6#

%$

>

6
6#

$%
(

$
>

>
&6%

&6%#$
+

&6%#

Cdigo en Visual Basic 2008


Module Module1
Sub Main()
'Declaracin de variables
' Entrada(-Proceso)
Dim S, V As Single ' un par de valores de la lista
Dim Cent As String ' Centinela
' Proceso - Auxiliar
Dim Capturado1 As Integer 'Bandera Captura Primer Valor de S
Dim Capturado2 As Integer ' Bandera Captura del primer S | S > V
Dim PS As Single 'Primer valor de S de la lista
' Proceso - Salida
Dim C1 As Integer ' Cantidad de pares donde se repite PS en S
Dim C2 As Integer' Cantidad de veces donde S=2*V
Dim P As Single ' Productoria de S, (S<>0) AND (V=0)
' Salida
Dim PSV As Single' Primer valor de S | S > V
' iniciar contadores, productoria y banderas
Capturado1 = 0
Capturado2 = 0
C1 = 0
C2 = 0
P = 1
Do
Console.Write("Valor de S:")
S = Console.ReadLine
Console.WriteLine("Valor de V:")
V = Console.ReadLine
If Capturado1 = 0 Then
PS = S
Capturado1 = 1
Else
If S = PS Then
C1 = C1 + 1
End If
End If

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009
If S > V Then
If Capturado2 = 0 Then
PSV = S
Capturado2 = 1
End If
End If
If S = 2 * V Then
C2 = C2 + 1
End If
If (S <> 0) And (V = 0) Then
P = P * S
End If
Console.Write("Ultimo Par (S/N)?:")
Cent = Console.ReadLine
Loop Until (Cent = "S") Or (Cent = "s")

Console.WriteLine("Cantidad de veces que se repite el primer valor de


S:" & C1)
If Capturado2 = 0 Then
Console.WriteLine("En ningun par, S fue mayor que V")
Else
Console.WriteLine("Primer valor de S, donde S fue mayor que V:" &
PSV)
End If
Console.WriteLine("Cantidad de veces que S duplica a V:" & C2)
Console.WriteLine("Productoria de S donde V fue nulo:" & P)
'para que la ventana de ejecucin no se cierre
Console.ReadKey()
End Sub
End Module

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009

Ejercicio 2
)

4
4

1)
2)
3)

4
4

4
4

Anlisis del Problema


!
*
" ;
$

!
4

"
" )

*
;

$
#%!(<

$ ,
7 !(

' )

.
. .
4

- 4
*
4

;
.

"
$

<,

Tabla de Variables
*

*
#%!(
;
#%!(

*
;

#%!(

;
!6;

% ;

2
2
2

3
3
23
23

2 ,4
2 ,4
2 ,4
2 ,4

2
2

23
3
23

2 ,4
2 ,4
2 ,4

2
2
2

3
23
23

2 ,4
2 ,4
2 ,4

2
2
2

#%!(

7!(

78 "= $&!((
"6;
7 !(
$6

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009

Algoritmo
!
4&!

"#
!
!

&!
&
#

"
&

+&!
?&!
#
# &!
# &!
)&!
$
# &'

-.)2

1 )2
"$
-.)2
#

-.)2
(

>

4
5
1" 2
) 1" 2
+ 1" 2
? 1" 2
'
4
7
4
7
$

&6

4
6

&6

-.)2
$

.2
#
#

1"
1"

4
1" )

$
$
) 1"
9 $
9 $

.#
)8)

$
+ 1" + 8 )
9 $
? 1" ? 8 )
4
6:
!
7
<
0
. 6$63 =' 0
$
.2
4
6
A
$
4
6#
4
69
4
65
9 $
# 1" +; ?/)22
4
6#
@

0$; 3 &6
. 6 63
6
&6% #
&6% #
&6% )

'

&6%#

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009

Cdigo en Visual Basic 2008


Module Module1
Sub Main()
'Declaracin de Variables
' Entrada - Proceso
Dim CI As Integer ' Cedula del Estudiante
Dim Nota As Integer ' Nota del Estudiane
Dim Cent As String 'Centinela
' Proceso - Auxiliar
Dim Capturado As Integer 'Bandera Captura Cedula y Nota | Nota >=10
Dim C2 As Integer ' Cantidad de Notas < 10
Dim C3 As Integer ' Cantidad Total de Notas
' Proceso
Dim PC As
Dim PN As
Dim C1 As

- Salida
Integer ' Cedula de la primera Nota >=10
Integer ' Primer Nota >=10
Integer ' Cantidad de veces que se repite PN en Nota

' Salida
Dim Por As Single

' Porcentaje de reprobados

' iniciar contadores y bandera


Capturado = 0
C1 = 0
C2 = 0
C3 = 0
Do
Console.Write("Cedula del estudiante:")
CI = Console.ReadLine
Console.Write("Nota del estudiante:")
Nota = Console.ReadLine
If Nota >= 10 Then
If Capturado = 0 Then
PC = CI
PN = Nota
Capturado = 1
Else
If Nota = PN Then
C1 = C1 + 1
End If
End If
Else
' esta reprobado
C2 = C2 + 1
End If
C3 = C3 + 1
Console.Write("Ultimo Estudiante (S/N)?:")
Cent = Console.ReadLine
Loop Until (Cent = "S") Or (Cent = "s")

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009
If Capturado = 0 Then
Console.WriteLine("No hubo estudiantes aprobados en la lista")
Else
Console.WriteLine("Primera Nota aprobatoria de la lista:" & PN)
Console.WriteLine("Fue obtenida por:" & PC)
Console.WriteLine("y se repitio en la lista:" & C1)
End If
Por = C2 / C3 * 100
Console.WriteLine("Porcentaje de Reprobados:" & Por)
'para que la ventana de ejecucin no se cierre
Console.ReadKey()
End Sub
End Module

Ejercicio 3
)

>

1)
2)
3)

,
,

?
?

Anlisis del Problema


!

?
>

"

!
"
$

? 6 ? 7%(
?6 ?#(
?%(

" )
?

!<
?%(
"<
?#(

*
? 7% (
@
-

Tabla de Variables
?
?
? 7%(
?%(
?#(
?%(

>
?
!
"
78

"=>&!((

2
2

23
3
3
23
23
3

2 ,4
2 ,4
2 ,4
2 ,4
2 ,4
2 ,4

2
2
2
2
2
2

10

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009

Algoritmo
!

"#

&!
&'
#
4&!
+&!
#
$) & '
# &'
$
# &'

(
(
"
(
"$
$
#

>

.2

, 1. 2
, -2

.2

4
%
$) 1" 2
+ 1" 2
# 1" )
4
6
7
#
4 1" ) A
A
4
6
7
$
1. 2
$) 1" $) 8
$
.2
+ 1" + 8 )
9 $
$
(
# 1" # /

&6

&6

9
4
4
#
4

1"

6$
6#
+; /)22
6#

(
(
@

1.2&6%$)
-2&6%#

&6%#

Cdigo en Visual Basic 2008


Module Module1
Sub Main()
'Declaracin de Variables
' Entrada - Proceso
Dim Q As Integer ' Cantidad de valores de A
Dim A As Single ' Cada valor de A
' Proceso - Auxiliar
Dim I As Integer ' Variable de control
Dim C2 As Integer ' Cantidad de veces que A=0
' Proceso - Salid
Dim S1 As Single ' Sumatoria de A | A <= 0
Dim P As Single ' Productoria de A | A > 0
' Salida
Dim Por As Single ' Porcentaje de A=0

11

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009
' iniciar sumador & contador y productoria
S1 = 0
C2 = 0
P = 1
Console.Write("Cantidad de valores de A:")
Q = Console.ReadLine
For I = 1 To Q
Console.Write("Valor de A:")
A = Console.ReadLine
If A <= 0 Then
S1 = S1 + A
If A = 0 Then
C2 = C2 + 1
End If
Else
' A es poiftivo no nulo
P = P * A
End If
Next I
Console.WriteLine("Sumatoria de valores de A <=0:" & S1)
Console.WriteLine("Productoria de valores de A>0:" & P)
Por = C2 / Q * 100
Console.WriteLine("Porcentaje de valores de A nulos:" & Por)
'para que la ventana de ejecucin no se cierre
Console.ReadKey()
End Sub
End Module

Ejercicio 4
)

A!

1)

A!

2) ,
3)
4)

A"

A"
A!

A"

"

A!&A"

*
A!

A"

12

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009

Anlisis del Problema


!
"
$

A!
A"

!
" B
A"
$

A!
*

A"

!
A!
" )

*
A!

A"
B

*
'

A!
-

$ ,
*

*
.

A"

"
' ,
-

/ )

*
*

1
*

Tabla de Variables
A!
A"

A!
A"
A!
*

B
5

A"
A!

78 A!DA" ="
78 A!&A" E( /

A"

2
2
2
2
2

3
3
23
3
3
23

2 ,4
2 ,4
2 ,4
2 ,4
2 ,4
2 ,4

2
2

2
2
2

*
A!

A!

2 ,4

A"

A"

2 ,4

23

2 ,4

"

23

2 ,4

*
F

13

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009

Algoritmo
!
"#
B)% B+ & '
&
#
"
)&!
+&!
&!
#
"$
# &'
#
CD & '
C
#B)% #B+ & '
$
# &'
#

>

1 CD

B) 5 B+
D

B) 5 B+
# .CD

#
@ >

# 1CD

4
) 1" 2
+ 1" 2
1" 2
'
4
6
B)&6
7
B)
4
6
B+&6
7
B+
# 1" 0B)8B+3;+
4
6#
&6%#
CD 1" 0B)/B+3E2FG
4
6C
D
$ # 1 CD
) 1" ) 8 )
$
$ # . CD
$
.2
#B) 1" B)
#B+ 1" B+
1" )
9
9 $
9
+ 1" + 8 )
4
6:
0$;
7
<
0
. 6$63 =' 0
# 1" ); +/)22
4
6#
@
$
.2
4
6!
$
4
6B)
4
6B+
9

&6% CD

3 &6
. 6 63
1C

&6%#
C

#
#

#
#

.C
.C

D
D
D

6
&6%#B)
&6%#B+

14

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009

Cdigo en Visual Basic 2008


Module Module1
Sub Main()
'Declaracin de Variables
' Entrada - Proceso
Dim X1, X2 As ifngle ' Cada par de valores
Dim Cent As String ' Centinela
' Proceso - Auxiliar
Dim C1 As Integer ' Cantidad de veces que Pro < MG
Dim C2 As Integer ' Cantidad total de pares
Dim Capturado As Integer 'bandera
' Proceso - Salida
Dim Pro As ifngle ' Promedio de X1 y X2
Dim MG As ifngle ' Media Geometrica de X1 y X2
Dim PX1, PX2 As ifngle ' Primer par donde Pro=MG
' Salida
Dim Por As Single ' Porcentaje que Pro<MG
' iniciar
C1 = 0
C2 = 0
Capturado = 0
Do
Console.Write("Valor de X1:")
X1 = Console.ReadLine
Console.Write("Valor de X2:")
X2 = Console.ReadLine
Pro = (X1 + X2) / 2
Console.WriteLine("Promedio:" & Pro)
MG = (X1 * X2) ^ 0.5
Console.WriteLine("Media Geometrica:" & MG)
If Pro < MG Then
C1 = C1 + 1
Else
If Pro = MG Then
If Capturado = 0 Then
PX1 = X1
PX2 = X2
Capturado = 1
End If
End If
End If
C2 = C2 + 1
Console.Write("Ultimo par (S/N)?:")
Leer(Cent)
Loop Until (Cent = "S") Or (Cent = "s")
Por = C1 / C2 * 100
Console.writeln("Porcentaje donde el promedio < Media Geometrico:", Por)

If Capturado = 0 Then
Console.WriteLine("En ningun par el promedio fue igual a la Media
Geometrica")
Else
Console.WriteLine("X1 del primer Par donde Promedio=Media
Geometrica:", PX1)

15

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009
Console.WriteLine("X2 del primer Par donde Promedio=Media
Geometrica:", PX2)
End If
'para que la ventana de ejecucin no se cierre
Console.ReadKey()
End Sub
End Module

Ejercicio 5
A! G!
A"8A" "D G"8G! " )

G"

A"

,
+

1)
2)

@
H" %

3)

4
!" D

4
@

""

Anlisis del Problema


! I

! I :
-

@
@

"

"
$ , -4

@
$
@
@

' ,
@
94

+
@

-4

4
@
,! ," ,$
,!%,"
,$ 4 ,!%,$
," 4
,"%,$
,!
. .
4
!
. .
@
"
@
@
. .
$
$
,!%,"%,$
"

' )

.
@

.
4
@

16

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009

Tabla de Variables

,
A!
G!
A"
G"
A$
G$
9
,!

2
2
2
2
2
2

23
3
3
3
3
3
3
23
3

2 ,4
2 ,4
2 ,4
2 ,4
2 ,4
2 ,4
2 ,4
2 ,4
2 ,4

2
2
2
2
2
2
2
2
2

,"

2 ,4

2
2

3
3
23
23
3

2 ,4
2 ,4
2 ,4
2 ,4
2 ,4

2
2
2
2
2

23

2 ,4

23

2 ,4

23

2 ,4

?
2
?
2
?
2

,$
F @
@

9 4
9 4

!%

!= " & !((

"%

$= ! &!((

!
"

@
9 4

@
9 4

@
5
-

5
@

@
-

A! G! A" G" A$ G$

Algoritmo

!
"#
7&!
B)%H)%B+%H+%B?%H? & '
#
"
4&!
(
7)% 7+% 7? & '
)&!
+&!
?&!
*
&!

>
*

>

$
# )&'
@
# +&'
@
#B)%#H)%#B+%#H+%#B?%#H? & !

4
4
#

5
>

>

4
) 1" 2
+ 1" 2
? 1" 2
*
4
7

1" 2 2.
6

% ).H
$

&6

17

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009
#

4 1" ) A
7A
4
6
&6
7
B)
4
6=
&6
7
H)
4
6
&6
7
B+
4
6=
&6
7
H+
4
6
&6
7
B?
4
6=
&6
7
H?
7) 1" 00B+"B)3/0B+"B)380H+"H)3/0H+"H)33E2FG
7+ 1" 00B?"B+3/0B?"B+380H?"H+3/0H?"H+33E2FG
7? 1" 00B)"B?3/0B)"B?380H)"H?3/0H)"H?33E2FG
+ 1" + 8 )
$ 07).7+3
07+1-7?3 =' 07).7?3
07?1-7+3 =' 07+.7?3
)8)
7) <
$ 07)^2.7+^287?^23

07?1-7)3

) 1"

7+ <
7? <
07+^2.7)^287?^23
07?^2.7)^287+^23

? 1" ? 8 )
9 $
9 $
$ 07).7+3
07+.7?3
>
$ *
.2
#B) 1" B)
#H) 1" H)
#B+ 1" B+
#H+ 1" H+
#B? 1" B?
#H? 1" H?
*
1" )
9 $
9 $
9 #
# ) 1" ); +/)22
4
6#
@
4
$ ).2
4
6
A
4
$
# + 1" ?; ) / )22
4
6#
@
9 $
$ *
.2
4
6
A
>
$
4
6
4
6#
)& 06%#B)%6%6%#H)%636
4
6#
+& 06%#B+%6%6%#H+%636
4
6#
?& 06%#B?%6%6%#H?%636
9 $

&6%# )
6

&6%# +

6
>

18

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009

Cdigo en Visual Basic 2008


Module Module1
Sub Main()
'Declaracin de Variables
' Entrada - Proceso
Dim L As Integer ' Cantidad de sextetos
Dim X1, Y1, X2, Y2, X3, Y3 As Single ' Coordenadas de los tres puntos
' Proceso - Auxiliar
Dim I As Integer ' variable de control
Dim L1, L2, L3 As Single ' Longitud de los lados del triangulo
Dim C1 As Integer ' Cantidad de triangulos isosceles
Dim C2 As Integer ' Cantidad total de triangulos
Dim C3 As Integer ' Cantidad de triangulos isosceles que son
rectangulo
Dim Bandera As Integer ' Bandera for capturar los puntos del primer
equilatero
' Salida
Dim Por1 As Single ' porcentaje de Triangulos Isosceles
Dim Por2 As Single ' porcentaje de Triangulos Isosceles y rectngulos
Dim PX1, PY1, PX2, PY2, PX3, PY3 As Integer ' Puntos que formaron el
primer equilatero
C1 = 0
C2 = 0
C3 = 0
Bandera = 0 ' 0=No he capturado, 1=Ya capture
Console.Write("Cantidad de Sextetosas")
L = Console.ReadLine
For I = 1 To L
Console.Write("Abscisa del primer punto: ")
X1 = Console.ReadLine
Console.Write("Ordenada del primer punto: ")
Y1 = Console.ReadLine
Console.Write("Abscisa del segundo punto:")
X2 = Console.ReadLine
Console.Write("Ordenada del segundo punto:")
Y2 = Console.ReadLine
Console.Write("Abscisa del tercer punto:")
X3 = Console.ReadLine
Console.Write("Ordenada del tercer punto:")
Y3 = Console.ReadLine
L1 = ((X2 - X1) * (X2 - X1) + (Y2 - Y1) * (Y2 - Y1)) ^ 0.5
L2 = ((X3 - X2) * (X3 - X2) + (Y3 - Y2) * (Y3 - Y2)) ^ 0.5
L3 = ((X1 - X3) * (X1 - X3) + (Y1 - Y3) * (Y1 - Y3)) ^ 0.5
C2 = C2 + 1
If (L1 = L2) And (L2 <> L3) Or (L1 = L3) And (L3 <> L2) Or (L2 =
L3) And (L3 <> L1) Then
' es isosceles
C1 = C1 + 1
' Caso L1 Hipotenusa or L2 Hipotenusa or L3 Hipotenusa
If (L1^2 = L2^2 + L3^2 ) Or (L2 ^2= L1 ^2+ L3 ^2) Or (L3 ^2=
L1 ^2+ L2 ^2) Then

19

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009
' es rectangulo
C3 = C3 + 1
End If
End If
If (L1 = L2) And (L2 = L3) Then
' es equilatero
If Bandera = 0 Then
PX1 = X1
PY1 = Y1
PX2 = X2
PY2 = Y2
PX3 = X3
PY3 = Y3
Bandera = 1
End If
End If
Next I
Por1 = C1 / C2 * 100
Console.WriteLine("Porcentaje de Triangulos Isoscelesas", Por1)
If C1 = 0 Then
Console.WriteLine("No hubo triangulos Isosceles for saber if eran
rectangulos")
Else
Por2 = C3 / C1 * 100
Console.WriteLine("Porcentaje de Triangulos isosceles
rectangulosas", Por2)
End If
If Bandera = 0 Then
Console.WriteLine("No hubo triangulos equilateros")
Else
Console.WriteLine("Coordenadas del primer triangulo equilatero de
la lista")
Console.WriteLine("Punto 1as (" & PX1 & "," & PY1 & ")")
Console.WriteLine("Punto 2as (" & PX2 & "," & PY2 & ")")
Console.WriteLine("Punto 3as (" & PX3 & "," & PY3 & ")")
End If

'Para que la ventana de ejecucin no se cierre


Console.ReadKey()
End Sub
End Module

Ejercicio 6
-

(%-

!%
!%

"%

$%

'%

20

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009

1)
2)
3) ;
4)

'( J

Anlisis del Problema


! ;
"
$ )
'
/ F
0

"

F
# '(

" )

J
$ ;

%(
!

F
'

J
%(

!<
%"
$ ,

%"

.
'

$ ,

*
1

FF

;
' ,

"

# '(
FF

"
/ )

*
.
.
'( J

Tabla de Variables
;

J
%(
%(
!
#'(
# '(
"
FF

FF
FF
5
B
;

FF

! 78 != !
!
!

FF
B
B

FF
FF
%(

" 78 "= "


"
"
5
B
B;
B
78 $= ' &!((
$

2
2
2

23
23
23
23
23
23
3
3
23
3
23
23
23
23
23
23
3
23

2 ,4
2 ,4
2 ,4
2 ,4
2 ,4
2 ,4
2 ,4
2 ,4
2 ,4
2 ,4
2 ,4
2 ,4
2 ,4
2 ,4
2 ,4
2 ,4
2 ,4
2 ,4

2
2
2
2

2
2
2
2
2
2
2
2

2
2
2

23

2 ,4

%"
'

21

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009

Algoritmo
!
$
!

"#
&
&!
&!
&!
&!
&

2.9
).

%).C
%+.

%?.

#
"
$) & !
)&!
$+ & !
+&!
*
&!
?&!
I&!
C 5
&!
$
# )&'
# +&'
C
&
C!
&!

%I.

@
(

$)
!
- I2
(
>
$+
5
@
>
C @

$
*

>

C 5
#
#

C @
- I2

5
#

&'

4
$) 1" 2
) 1" 2
$+ 1" 2
+ 1" 2
*
1" 2
? 1" 2
I 1" 2
'
4
6
7
4
6$
02.9
7
$
4
6
7
4
6!
&6
7
!
4
6
7
$ $
.2
$) 1" $) 8 !
) 1" ) 8 )
$
.+
? 1" ? 8 )
9 $
9 $
I 1" I 8 )
$ !
- I2
$+ 1" $+ 8
+ 1" + 8 )
9
$ *
.2

&6
% ).C
0).

3&6
%+.

%?.

%I.

3&6

&6

22

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009
C 5
C
C!
*

1"
1"
1" !
1" )

$
$

-C 5
C 5 1"
C
1"
C!
1" !
9 $
9 $
4
6:
7
<
$

0
).2
4

.6$63
6

0$; 3& 6

.6 63

>

$
# ) 1" $); )
4
6#
9 $
$ +.2
4
6
<
$
# + 1" $+; +
4
6#
9 $
4
6
4
6!
# 1" ?; I/)22
4
6#

C @

&6%# )

I2 J

>

- I2&6%# +

5
@

>

@
@

&6% C
&6%C!
&6%#

Cdigo en Visual Basic 2008


Module Module1
Sub Main()
'Declaracin de Variables
' Entrada - Proceso
Dim Nombre As String
Dim Sexo As Integer ' 0=Femenino , 1=Masculino
Dim Dpto As Integer ' 1=compras,2=contabilidad,3=control de calidad, 4=ingenieria
Dim Edad As Integer
Dim TT As Integer ' Tiempo en aos Trabajado en la empresa
Dim Cent As String
' Proceso Dim
Dim
Dim
Dim
Dim
Dim
Dim
Dim

Auxiliar
S1 As Integer ' Sumatoria de edad de las mujeres
C1 As Integer ' Cantidad de veces que S1 sumo
S2 As Integer ' Sumatoria de TT Edad > 40
C2 As Integer ' Cantidad de veces que S2 sumo
Bandera As Integer ' Bandera para mayor TT
C3 As Integer ' cantidad de mujeres que trabajan en contabilidad
C4 As Integer ' cantidad Total de Mujeres
Mayor As Integer ' Mayor TT

23

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009
' Salida
Dim Pro1 As Single ' Promedio de Edad de las Mujeres
Dim Pro2 As Single ' Promedio de TT con Edad > 40
Dim MNombre As String ' Nombre del empleado con mayor TT
Dim MEdad As Integer ' Edad del empleado con mayor TT
Dim Por As Single ' Porcentaje de mujeres en contabilidad
S1 = 0
C1 = 0
S2 = 0
C2 = 0
Bandera = 0
C3 = 0
C4 = 0
Do
Console.Write("Nombre de la Persona:")
Nombre = Console.ReadLine
Console.Write("Sexo (0=Femenino , 1=Masculino):")
Sexo = Console.ReadLine
Console.Write("Departamento (1=compras , 2=contabilidad ,
3=control de calidad ,4=ingenieria):")
Dpto = Console.ReadLine
Console.Write("Edad:")
Edad = Console.ReadLine
Console.Write("Tiempo en aos trabajado en la empresa:")
TT = Console.ReadLine
If Sexo = 0 Then
S1 = S1 + Edad
C1 = C1 + 1
If Dpto = 2 Then
C3 = C3 + 1
End If
End If
C4 = C4 + 1
If Edad > 40 Then
S2 = S2 + TT
C2 = C2 + 1
End If
If Bandera = 0 Then
Mayor = TT
MNombre = Nombre
MEdad = Edad
Bandera = 1
Else
If TT > Mayor Then
Mayor = TT
MNombre = Nombre
MEdad = Edad
End If
End If
Console.Write("Ultimo Trabajador (S/N)?")
Cent = Console.ReadLine
Loop Until (Cent = "S") Or (Cent = "s")

24

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009
If C1 = 0 Then
Console.WriteLine("No hubo empleadas a quienes calcular el
promedio de la edad")
Else
Pro1 = S1 / C1
Console.WriteLine("Promedio de Edad de las Mujeres:" & Pro1)
End If
If C2 = 0 Then
Console.WriteLine("No Hubo empleados mayores de 40 aos para el
promedio")
Else
Pro2 = S2 / C2
Console.WriteLine("Promedio de tiempo trabajado de aquellos con
edad > 40:" & Pro2)
End If
Console.WriteLine("Nombre del empleado con mayor tiempo trabajado:" &
MNombre)
Console.WriteLine("Edad del empleado con mayor tiempo trabajado:" &
MEdad)
Por = C3 / C4 * 100
Console.WriteLine("Porcentaje de mujeres que trabajan en
contabilidadas" & Por)

'Para que la ventana de ejecucin no se cierre


Console.ReadKey()
End Sub
End Module

Ejercicio 7
)

+
1

,
,

(%

!%

"%

5 !((((
5 "/(((

.
)

5 /(((

5 K/((

1)
2) ;
3) ;
4)

.
+
.

25

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009

Anlisis del Problema


! ;
" )+
$ H
F
' H
F
/

!
)

" ;
.

" )

%(
!

$ ;

!<
%"

.
'

@
$ ,

) %(
'
$ ,

*
1

FF
;

' ,

# '(
"

FF

"
/ )

.
'(

Tabla de Variables
;
)+
H
H

;
)
H)
H;

)
;

BF

2
2

23
23
23
23
23
3

2 ,4
2 ,4
2 ,4
2 ,4
2 ,4
2 ,4

2
2
2

23

2 ,4

23

2 ,4

2
2

23
3
23
23
3
23
23

2 ,4
2 ,4
2 ,4
2 ,4
2 ,4
2 ,4
2 ,4

2
2

2
2
2
2

H;#H)
;

;
H; # ;)

5
B
;
)+

BF

5
B
B;
B)

BF
B

BF

BF
.
.

) %(

"

78 != !
!

!
!

26

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009

Algoritmo
$
!

"#
&

$&!
2.
% ).
% +.
% ?.C
%
< &!
<
< &!
<
&
#
"
*
)&!
*
@
< -<
*
+&!
*
5 C
C 5 &'
C 5 C
$) & !
$
<
$.2
)&!
(
>
$)
#
"$
C &'
$
@
#
&
@
< -<
C
&
5 C
C
&!
C 5 C
$
# &'
#
A
$.2
4
*
) 1" 2
2.
A
% ).H
*
+ 1" 2 2.
A 5
5
% ).!
5
$) 1" 2
) 1" 2
'
4
6
&6
7
4
6
$
02. %).7 %+.C %?.C %I.K %G. %L.$ 3&6
7
$
4
6<
&6
7
<
4
6<
&6
7
<
$ $.2
C 1" < /)G2228< /?+G22
$) 1" $) 8 < 8 <
) 1" ) 8 )
$
C 1" < /)22228< /+G222
9 $
4
%6&6%C
$ < -<
$ *
).2
#
1"
*
) 1" )
94 $
9 $
$ *
+.2
C 5 1" C
C
1"
C
1" $
*
+ 1" )
$
$ C -C 5

27

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009
C 5 1" C
C
1"
C
1" $
9 $
9 $
4
6:
7
<
0
.6$63
0
$ *
).2
4
6
A
$
4
6
9 $4
4
6
4
6
$ ).2
4
6
A
$
# 1" $); )
4
6#
9 $

0$; 3 &6
.6 63
@

<

-< 6

<
5

&6% C
5

- < &6%#

&6%C

&6% #

Cdigo en Visual Basic 2008


Module Module1
Sub Main()
'Declaracin de Variables
' Entrada - Proceso
Dim Nombre As String ' Nombre del empleado
Dim DS As Integer
' 0=domingo, 1=lunes, 2=martes, 3=Miercoles,
etc
Dim HD As Integer
' Horas diurnas
Dim HN As Integer
' Horas Nocturnas
Dim Cent As String
' Centinela
' Proceso - Auxiliar
Dim Bandera1 As Integer ' Bandera para capturar primer trabajador
HN>HD
Dim
Dim
Dim
Dim

Bandera2 As Integer ' Bandera para el mayor MT


Mayor As Single ' Mayor MT
S1 As Integer ' Sumatoria de Hora con DS=0
C1 As Integer ' Cantidad de veces que S1 sumo

' Proceso - Salida


Dim MT As Single ' Salario a cobrar por cada trabajador
Dim PNombre As String ' Nombre del primer trabajador HN>HD
Dim MNombre As String ' Nombre del mayor MT
Dim MDia As Integer ' Dia del Mayor MT
' Salida
Dim Pro As Single ' Proemdio de horas en DS=0
Bandera1 = 0 ' 0=No he capturado, 1=Ya capture
Bandera2 = 0 ' 0=No hay un mayor aun, 1=Existe un mayor
S1 = 0
C1 = 0

28

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009
Do
Console.Write("Nombre del empleado : ")
Nombre = Console.ReadLine
Console.Write("Dia de la Semana (0=Do , 1=Lu , 2=Ma , 3=Mi , 4=Ju
, 5=Vi , 6=Sa) : ")
DS = Console.ReadLine
Console.Write("Hor: Diurn: : ")
HD = Console.ReadLine
Console.Write("Hor: Nocturnas : ")
HN = Console.ReadLine
If DS = 0 Then
MT = HD * 15000 + HN * 32500
S1 = S1 + HD + HN
C1 = C1 + 1
Else
MT = HD * 10000 + HN * 25000
End If
Console.WriteLine(Nombre & " : " & MT)
If HN > HD Then
If Bandera1 = 0 Then
PNombre = Nombre
Bandera1 = 1
End If
End If
If Bandera2 = 0 Then
Mayor = MT
MNombre = Nombre
MDia = DS
Bandera2 = 1
Else
If MT > Mayor Then
Mayor = MT
MNombre = Nombre
MDia = DS
End If
End If
Console.Write("Ultimo empleado (S/N)? : ")
Cent = Console.ReadLine
Loop Until (Cent = "S") Or (Cent = "s")
If Bandera1 = 0 Then
Console.WriteLine("No hubo trabajadores con HN > HD")
Else
Console.WriteLine("Nombre del primer trabajador con HN > HD : " & PNombre)

End If
Console.WriteLine("Nombre de la persona con mayor salario : " & MNombre)
Console.WriteLine("Dia de la semana donde gano el mayor salario : " & MDia)

If C1 = 0 Then
Console.WriteLine("No hubo trabajadores en Domingo")
Else
Pro = S1 / C1
Console.WriteLine("Promedio de horas los domingos :
End If

" & Pro)

'para que la ventana de ejecucin no se cierre


Console.ReadKey()
End Sub
End Module

29

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009

Ejercicio 8
B ; ?
K'

,
-

1)
2)
3)
4)
5)

@ @ @

L(

!((

Algoritmo
A
!
#

"#
&
&!
&

#
"
+&!
?&!
*
)&!
*
+&!
#
"$
)&!
I&!
C 5 &!
C
&!
$
# &'
#

'
*
*

#
#
C 5
C

-. MI
NO2%)22P

@
@

'

4
) 1" 2
+ 1" 2
? 1" 2
*
*

) 1" 2
+ 1" 2

I 1" 2
'
4
6
&6
7
4
6#
7
#
$ #
-. MI
) 1" ) 8 )
$ 0#
-. O23
I 1" I 8 )
9 $
$
#
1 MI
+ 1" + 8 )

&6

0#

1. )223

30

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009
9 $
? 1" ? 8 )
$ *
).2
C 5 1" #
*
) 1" )
$
$ #
-C 5
C 5 1" #
9 $
9 $
$ *
+.2
C
1" #
*
) 1" )
$
$ #
1C
C
1" #
9 $
9 $
4
6:
7
<
0
.6$63
0
4
6
# 1" +; ?/)22
4
6#
@
4
6C 5 #
4
6C
#
4
6

&6
.6 63
>

&6% )
&6%#

@ &6%C 5
@ &6%C
#

NO2%)22P&6% I

Cdigo en Visual Basic 2008


Module Module1
Sub Main()
'Declaracin de Variables
' Entrada - Proceso
Dim Nombre As String
Dim Puntos As Integer
Dim Cent As String
' Proceso - Auxiliar
Dim C2 As Integer ' Cantidad de Reprobados
Dim C3 As Integer ' Cantidad total de Candidatos
Dim Bandera1 As Integer ' Bandera para el mayor ptos
Dim Bandera2 As Integer ' Bandera para el menor ptos
' Proceso - Salida
Dim C1 As Integer ' Cantidad de candidatos con Ptos >= 74
Dim C4 As Integer ' Cantidad de cantidatos con Ptos entre [80,100]
Dim Mayor As Integer ' Mayor puntaje
Dim Menor As Integer ' Menor puntaje
' Salida
Dim Por As Single ' Porcentaje de Candidatos Reprobados
C1 = 0
C2 = 0
C3 = 0
Bandera1 = 0
Bandera2 = 0

31

Ejercicios del Primer Parcial En VB2008


Perodo
2-2009
C4 = 0
Do
Console.Write("Nombre:")
Nombre = Console.ReadLine
Console.Write("Puntos obtenidos:")
Puntos = Console.ReadLine
If Puntos >= 74 Then
C1 = C1 + 1
If (Puntos >= 80) And (Puntos <= 100) Then
C4 = C4 + 1
End If
Else ' Puntos < 74
C2 = C2 + 1
End If
C3 = C3 + 1
If Bandera1 = 0 Then
Mayor = Puntos
Bandera1 = 1
Else
If Puntos > Mayor Then
Mayor = Puntos
End If
End If
If Bandera2 = 0 Then
Menor = Puntos
Bandera1 = 1
Else
If Puntos < Menor Then
Menor = Puntos
End If
End If
Console.Write("Ultimo Candidato:")
Cent = Console.ReadLine
Loop Until (Cent = "S") Or (Cent = "s")
Console.WriteLine("Cantidad de Candidatos que aprobaron el test:" &
C1)
Por = C2 / C3 * 100
Console.WriteLine("Porcentaje de Candidatos reprobados:" & Por)
Console.WriteLine("Mayor Puntaje:" & Mayor)
Console.WriteLine("Menor Puntaje:" & Menor)
Console.WriteLine("Cantidad de Candidatos con Puntos entre [80 &
100]:" & C4)

'para que la ventana de ejecucin no se cierre


Console.ReadKey()
End Sub
End Module

32

Potrebbero piacerti anche