• Lenguaje

    Pascal

  • Descripción

    Controlar los asistentes a una fiesta; para esto deberá ingresar la edad, sexo (masculino y femenino) y estado civil del asistente (soltero, casado, viudo o divorciado), luego mostrar las siguientes estadísticas:
    a) Total de asistentes.
    b) Total de personas mayores de edad.
    c) Total de personas menores de edad.
    d) Total de hombres.
    e) Total de mujeres.
    f) Total de solteros.
    g) Total de casados.
    h) Total de viudos.
    i) Total de divorciados.
    j) Porcentaje de hombres.
    k) Porcentaje de mujeres.

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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
program EstadisticasDeUnaFiesta;
uses crt;

var a, b, c, d, e : integer;
var edad, estado_civil, f, g, h : integer;
var i, sexo : integer;
var j, k : real;
var tecla_repetir : char;
begin
    a := 0;
    b := 0;
    c := 0;
    d := 0;
    e := 0;
    f := 0;
    g := 0;
    h := 0;
    i := 0;
    j := 0;
    k := 0;
    repeat
        clrscr;
        write ('Ingresa el valor de edad: ');
        readln (edad);
        writeln ('Selecciona el valor de sexo.');
        writeln ('    1.- masculino');
        writeln ('    2.- femenino');
        write ('    : ');
        repeat
            readln (sexo);
            if (sexo<1) or (sexo>2) then
                write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
        until (sexo>=1) and (sexo<=2);
        writeln ('Selecciona el valor de estado civil.');
        writeln ('    1.- soltero');
        writeln ('    2.- casado');
        writeln ('    3.- viudo');
        writeln ('    4.- divorciado');
        write ('    : ');
        repeat
            readln (estado_civil);
            if (estado_civil<1) or (estado_civil>4) then
                write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
        until (estado_civil>=1) and (estado_civil<=4);
        a := a+1;
        if edad>=18 then
            begin
                b := b+1;
            end
        else
            begin
                c := c+1;
            end;
        if sexo=1 then
            begin
                d := d+1;
            end
        else
            begin
                e := e+1;
            end;
        if estado_civil=1 then
            begin
                f := f+1;
            end;
        if estado_civil=2 then
            begin
                g := g+1;
            end;
        if estado_civil=3 then
            begin
                h := h+1;
            end;
        if estado_civil=4 then
            begin
                i := i+1;
            end;
        writeln;
        write (#168'Deseas repetir el proceso? (S/N): ');
        repeat
            tecla_repetir := readkey;
        until (tecla_repetir = 's') or (tecla_repetir = 'n') or (tecla_repetir = 'S') or (tecla_repetir = 'N');
    until (tecla_repetir <> 's') and (tecla_repetir <> 'S');
    if a = 0 then
        j := 0
    else
        j := 100.0*d/a;
    if a = 0 then
        k := 0
    else
        k := 100.0*e/a;
    writeln ('Valor de a: ', a);
    writeln ('Valor de b: ', b);
    writeln ('Valor de c: ', c);
    writeln ('Valor de d: ', d);
    writeln ('Valor de e: ', e);
    writeln ('Valor de f: ', f);
    writeln ('Valor de g: ', g);
    writeln ('Valor de h: ', h);
    writeln ('Valor de i: ', i);
    writeln ('Valor de j: ', j:0:6);
    writeln ('Valor de k: ', k:0:6);
    write ('Presiona una tecla para terminar . . . ');
    readkey;
end.