• Lenguaje

    Pascal

  • Descripción

    La secretaría de salud requiere un algoritmo que permita determinar qué tipo de vacuna (A, B o C) debe aplicar a una persona, considerando que si es mayor de 70 años, sin importar el sexo, se le aplica la tipo C; si tiene entre 16 y 69 años, y es mujer, se le aplica la B, y si es hombre, la A; si es menor de 16 años, se le aplica la tipo A, sin importar el sexo.

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

var edad, sexo : integer;
begin
    write ('Ingresa el valor de edad: ');
    readln (edad);
    writeln ('Selecciona el valor de sexo.');
    writeln ('    1.- mujer');
    writeln ('    2.- hombre');
    write ('    : ');
    repeat
        readln (sexo);
        if (sexo<1) or (sexo>2) then
            write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
    until (sexo>=1) and (sexo<=2);
    if ((sexo=2) and (edad>=16) and (edad<70)) or (edad<16) then
        begin
            writeln ('A');
        end;
    if (sexo=1) and (edad>=16) and (edad<70) then
        begin
            writeln ('B');
        end;
    if edad>70 then
        begin
            writeln ('C');
        end;
    writeln;
    write ('Presiona una tecla para terminar . . . ');
    readkey;
end.