• Lenguaje

    Pascal

  • Descripción

    Controle los datos generales de los pacientes de un hospital: Nombre, edad, sexo, estatura, peso y tipo de sangre. Y determine:
    a) Número de hombres.
    b) Hombres con tipo de sangre A.
    c) Peso promedio de las mujeres.
    d) Estatura promedio general.
    e) Edad promedio general.

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
program DatosDePacientes;
uses crt;

var a, b, genero, pacientes, tipo_de_sangre : integer;
var c, d, e, edad, estatura : real;
var peso : real;
var nombre : string;
var tecla_repetir : char;
begin
    a := 0;
    b := 0;
    pacientes := 0;
    c := 0;
    d := 0;
    e := 0;
    repeat
        clrscr;
        write ('Ingresa el nombre: ');
        readln (nombre);
        write ('Ingresa el valor de edad: ');
        readln (edad);
        write ('Ingresa el valor de estatura: ');
        readln (estatura);
        write ('Ingresa el valor de peso: ');
        readln (peso);
        writeln ('Selecciona el valor de genero.');
        writeln ('    1.- Mujer');
        writeln ('    2.- Hombre');
        write ('    : ');
        repeat
            readln (genero);
            if (genero<1) or (genero>2) then
                write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
        until (genero>=1) and (genero<=2);
        writeln ('Selecciona el valor de tipo de sangre.');
        writeln ('    1.- A');
        writeln ('    2.- B');
        writeln ('    3.- O');
        writeln ('    4.- AB');
        write ('    : ');
        repeat
            readln (tipo_de_sangre);
            if (tipo_de_sangre<1) or (tipo_de_sangre>4) then
                write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
        until (tipo_de_sangre>=1) and (tipo_de_sangre<=4);
        pacientes := pacientes+1;
        d := d+estatura;
        e := e+edad;
        if genero=2 then
            begin
                a := a+1;
            end;
        if (genero=2) and (tipo_de_sangre=1) then
            begin
                b := b+1;
            end;
        if genero=c then
            begin
                c := c+peso;
            end;
        writeln ('Nombre: ', nombre);
        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');
    c := c/(pacientes-a);
    if pacientes = 0 then
        d := 0
    else
        d := d/pacientes;
    if pacientes = 0 then
        e := 0
    else
        e := e/pacientes;
    writeln ('Valor de a: ', a);
    writeln ('Valor de b: ', b);
    writeln ('Valor de pacientes: ', pacientes);
    writeln ('Valor de c: ', c:0:6);
    writeln ('Valor de d: ', d:0:6);
    writeln ('Valor de e: ', e:0:6);
    write ('Presiona una tecla para terminar . . . ');
    readkey;
end.