-
Lenguaje
Pascal
-
Descripción
En un hospital se ha hecho un estudio sobre los pacientes registrados durante los últimos 3 años, con el objeto de hacer una aproximación de los costos de internación por paciente. Se obtuvo un costo promedio diario según el tipo de enfermedad que aqueja el paciente. Además, se pudo determinar que en promedio todos los pacientes con edad entre 18 y 30 años implican un costo adicional del 4%. La siguiente tabla expresa los costos diarios, según tipo de enfermedad.
TIPO DE ENFERMEDAD | COSTO/PACIENTE/DIA
A | 30
B | 40
C | 50
D | 60
Calcular e imprimir el costo que representa un paciente.
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
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
program PacientesRegistradosEnUnHospital3;
uses crt;
var tipo_de_enfermedad : integer;
var costo, edad : real;
begin
write ('Ingresa el valor de edad: ');
readln (edad);
writeln ('Selecciona el valor de tipo de enfermedad.');
writeln (' 1.- A');
writeln (' 2.- B');
writeln (' 3.- C');
writeln (' 4.- D');
write (' : ');
repeat
readln (tipo_de_enfermedad);
if (tipo_de_enfermedad<1) or (tipo_de_enfermedad>4) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (tipo_de_enfermedad>=1) and (tipo_de_enfermedad<=4);
costo := 0;
if tipo_de_enfermedad=1 then
begin
costo := 30;
end;
if tipo_de_enfermedad=2 then
begin
costo := 40;
end;
if tipo_de_enfermedad=3 then
begin
costo := 50;
end;
if tipo_de_enfermedad=4 then
begin
costo := 60;
end;
if (edad>=18) and (edad<=30) then
begin
costo := costo*1.4;
end;
writeln ('Valor de costo: ', costo:0:6);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var tipo_de_enfermedad : integer;
var costo, edad : real;
begin
write ('Ingresa el valor de edad: ');
readln (edad);
writeln ('Selecciona el valor de tipo de enfermedad.');
writeln (' 1.- A');
writeln (' 2.- B');
writeln (' 3.- C');
writeln (' 4.- D');
write (' : ');
repeat
readln (tipo_de_enfermedad);
if (tipo_de_enfermedad<1) or (tipo_de_enfermedad>4) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (tipo_de_enfermedad>=1) and (tipo_de_enfermedad<=4);
costo := 0;
if tipo_de_enfermedad=1 then
begin
costo := 30;
end;
if tipo_de_enfermedad=2 then
begin
costo := 40;
end;
if tipo_de_enfermedad=3 then
begin
costo := 50;
end;
if tipo_de_enfermedad=4 then
begin
costo := 60;
end;
if (edad>=18) and (edad<=30) then
begin
costo := costo*1.4;
end;
writeln ('Valor de costo: ', costo:0:6);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.