-
Lenguaje
Pascal
-
Descripción
Construir un programa que calcule el índice de masa corporal de una persona (IMC = peso [kg] / altura2 [m]) e indique el estado en el que se encuentra esa persona en función del valor de IMC:
Valor de IMC | Diagnóstico
< 16 | Criterio de ingreso en hospital
De 16 a 17 | Infrapeso
De 17 a 18 | Bajo peso
De 18 a 25 | Peso normal (saludable)
De 25 a 30 | Sobrepeso (obesidad de grado I)
De 30 a 35 | Sobrepeso crónico (obesidad de grado II)
De 35 a 40 | Obesidad premórbida (obesidad de grado III)
> 40 | Obesidad mórbida (obesidad de grado IV)
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
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
program IndiceDeMasaCorporal;
uses crt;
var IMC, altura_en_m, peso_en_kg : real;
begin
write ('Ingresa el valor de altura en m: ');
readln (altura_en_m);
write ('Ingresa el valor de peso en kg: ');
readln (peso_en_kg);
IMC := peso_en_kg/altura_en_m/altura_en_m;
if IMC<16 then
begin
writeln ('Criterio de ingreso en hospital.');
end;
if (IMC>=16) and (IMC<17) then
begin
writeln ('Infrapeso.');
end;
if (IMC>=17) and (IMC<18) then
begin
writeln ('Bajo peso.');
end;
if (IMC>=18) and (IMC<25) then
begin
writeln ('Peso normal (saludable).');
end;
if (IMC>=5) and (IMC<30) then
begin
writeln ('Sobrepeso (obesidad de grado I).');
end;
if (IMC>=30) and (IMC<35) then
begin
writeln ('Sobrepeso cr'#162'nico (obesidad de grado II).');
end;
if (IMC>=35) and (IMC<40) then
begin
writeln ('Obesidad prem'#162'rbida (obesidad de grado III).');
end;
if IMC>=40 then
begin
writeln ('Obesidad m'#162'rbida (obesidad de grado IV).');
end;
writeln ('Valor de IMC: ', IMC:0:6);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var IMC, altura_en_m, peso_en_kg : real;
begin
write ('Ingresa el valor de altura en m: ');
readln (altura_en_m);
write ('Ingresa el valor de peso en kg: ');
readln (peso_en_kg);
IMC := peso_en_kg/altura_en_m/altura_en_m;
if IMC<16 then
begin
writeln ('Criterio de ingreso en hospital.');
end;
if (IMC>=16) and (IMC<17) then
begin
writeln ('Infrapeso.');
end;
if (IMC>=17) and (IMC<18) then
begin
writeln ('Bajo peso.');
end;
if (IMC>=18) and (IMC<25) then
begin
writeln ('Peso normal (saludable).');
end;
if (IMC>=5) and (IMC<30) then
begin
writeln ('Sobrepeso (obesidad de grado I).');
end;
if (IMC>=30) and (IMC<35) then
begin
writeln ('Sobrepeso cr'#162'nico (obesidad de grado II).');
end;
if (IMC>=35) and (IMC<40) then
begin
writeln ('Obesidad prem'#162'rbida (obesidad de grado III).');
end;
if IMC>=40 then
begin
writeln ('Obesidad m'#162'rbida (obesidad de grado IV).');
end;
writeln ('Valor de IMC: ', IMC:0:6);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.