-
Lenguaje
Visual Basic .Net
-
Descripción
Un maestro desea saber qué porcentaje de hombres y qué porcentaje de mujeres hay en un grupo de estudiantes.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Module PorcentajeDeMujeresYHombres
Sub Main()
Dim estudiantes, genero, hombres, mujeres As Integer
Dim porcentaje_hombres, porcentaje_mujeres As Double
Dim tecla_repetir As Char
estudiantes = 0
hombres = 0
mujeres = 0
porcentaje_hombres = 0
porcentaje_mujeres = 0
Do
Console.Clear()
Console.WriteLine("Selecciona el valor de genero.")
Console.WriteLine(vbTab & "1.- Mujer")
Console.WriteLine(vbTab & "2.- Hombre")
Console.Write(vbTab & ": ")
Do
genero = Integer.Parse(Console.ReadLine())
If genero < 1 Or genero > 2 Then
Console.Write("Valor incorrecto. Ingrésalo nuevamente.: ")
End If
Loop While genero < 1 Or genero > 2
If genero = 1 Then
mujeres=mujeres+1
Else
hombres=hombres+1
End If
Console.WriteLine()
Console.Write(ChrW(&HBF) & "Deseas repetir el proceso? (S/N): ")
Do
tecla_repetir = Console.ReadKey(True).KeyChar
Loop While tecla_repetir <> "s" And tecla_repetir <> "n" And tecla_repetir <> "S" And tecla_repetir <> "N"
Loop While tecla_repetir = "s" Or tecla_repetir = "S"
estudiantes=hombres+mujeres
If estudiantes = 0 Then
porcentaje_hombres = 0
Else
porcentaje_hombres=100.0*hombres/estudiantes
End IF
If estudiantes = 0 Then
porcentaje_mujeres = 0
Else
porcentaje_mujeres=100.0*mujeres/estudiantes
End IF
Console.WriteLine("Valor de estudiantes: " & estudiantes)
Console.WriteLine("Valor de hombres: " & hombres)
Console.WriteLine("Valor de mujeres: " & mujeres)
Console.WriteLine("Valor de porcentaje hombres: " & porcentaje_hombres)
Console.WriteLine("Valor de porcentaje mujeres: " & porcentaje_mujeres)
Shell ("cmd /c pause", AppWinStyle.NormalFocus, True)
End Sub
End Module
Sub Main()
Dim estudiantes, genero, hombres, mujeres As Integer
Dim porcentaje_hombres, porcentaje_mujeres As Double
Dim tecla_repetir As Char
estudiantes = 0
hombres = 0
mujeres = 0
porcentaje_hombres = 0
porcentaje_mujeres = 0
Do
Console.Clear()
Console.WriteLine("Selecciona el valor de genero.")
Console.WriteLine(vbTab & "1.- Mujer")
Console.WriteLine(vbTab & "2.- Hombre")
Console.Write(vbTab & ": ")
Do
genero = Integer.Parse(Console.ReadLine())
If genero < 1 Or genero > 2 Then
Console.Write("Valor incorrecto. Ingrésalo nuevamente.: ")
End If
Loop While genero < 1 Or genero > 2
If genero = 1 Then
mujeres=mujeres+1
Else
hombres=hombres+1
End If
Console.WriteLine()
Console.Write(ChrW(&HBF) & "Deseas repetir el proceso? (S/N): ")
Do
tecla_repetir = Console.ReadKey(True).KeyChar
Loop While tecla_repetir <> "s" And tecla_repetir <> "n" And tecla_repetir <> "S" And tecla_repetir <> "N"
Loop While tecla_repetir = "s" Or tecla_repetir = "S"
estudiantes=hombres+mujeres
If estudiantes = 0 Then
porcentaje_hombres = 0
Else
porcentaje_hombres=100.0*hombres/estudiantes
End IF
If estudiantes = 0 Then
porcentaje_mujeres = 0
Else
porcentaje_mujeres=100.0*mujeres/estudiantes
End IF
Console.WriteLine("Valor de estudiantes: " & estudiantes)
Console.WriteLine("Valor de hombres: " & hombres)
Console.WriteLine("Valor de mujeres: " & mujeres)
Console.WriteLine("Valor de porcentaje hombres: " & porcentaje_hombres)
Console.WriteLine("Valor de porcentaje mujeres: " & porcentaje_mujeres)
Shell ("cmd /c pause", AppWinStyle.NormalFocus, True)
End Sub
End Module