-
Lenguaje
Pascal
-
Descripción
Determinar el valor a pagar por hospedaje en un determinado hotel, de acuerdo a los siguientes requerimientos:
1.- Mostrar un menú de opciones donde se muestre el tipo de habitación y su precio: (Sencilla - $25, Doble - $40, Matrimonial - $65). El usuario debe elegir un solo tipo de habitación e indicar el número de días de hospedaje.
2.- Considerar un descuento del 8% si el número de días de hospedaje es mayor o igual a 3 y sólo para el tipo de habitación matrimonial.
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
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
program PagoPorHospedaje;
uses crt;
var tipo_de_habitacion : integer;
var descuento, dias_de_hospedaje, precio, subtotal, total : real;
begin
write ('Ingresa el valor de dias de hospedaje: ');
readln (dias_de_hospedaje);
precio := 0;
writeln ('Selecciona el valor de tipo de habitacion.');
writeln (' 1.- Sencilla');
writeln (' 2.- Doble');
writeln (' 3.- Matrimonial');
write (' : ');
repeat
readln (tipo_de_habitacion);
if (tipo_de_habitacion<1) or (tipo_de_habitacion>3) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (tipo_de_habitacion>=1) and (tipo_de_habitacion<=3);
if tipo_de_habitacion=1 then
begin
precio := 25;
end;
if tipo_de_habitacion=2 then
begin
precio := 40;
end;
if tipo_de_habitacion=3 then
begin
precio := 65;
end;
subtotal := dias_de_hospedaje*precio;
if (dias_de_hospedaje>=3) and (tipo_de_habitacion=3) then
begin
descuento := subtotal*0.08;
end
else
begin
descuento := 0;
end;
total := subtotal-descuento;
writeln ('Valor de descuento: ', descuento:0:6);
writeln ('Valor de precio: ', precio:0:6);
writeln ('Valor de subtotal: ', subtotal:0:6);
writeln ('Valor de total: ', total:0:6);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var tipo_de_habitacion : integer;
var descuento, dias_de_hospedaje, precio, subtotal, total : real;
begin
write ('Ingresa el valor de dias de hospedaje: ');
readln (dias_de_hospedaje);
precio := 0;
writeln ('Selecciona el valor de tipo de habitacion.');
writeln (' 1.- Sencilla');
writeln (' 2.- Doble');
writeln (' 3.- Matrimonial');
write (' : ');
repeat
readln (tipo_de_habitacion);
if (tipo_de_habitacion<1) or (tipo_de_habitacion>3) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (tipo_de_habitacion>=1) and (tipo_de_habitacion<=3);
if tipo_de_habitacion=1 then
begin
precio := 25;
end;
if tipo_de_habitacion=2 then
begin
precio := 40;
end;
if tipo_de_habitacion=3 then
begin
precio := 65;
end;
subtotal := dias_de_hospedaje*precio;
if (dias_de_hospedaje>=3) and (tipo_de_habitacion=3) then
begin
descuento := subtotal*0.08;
end
else
begin
descuento := 0;
end;
total := subtotal-descuento;
writeln ('Valor de descuento: ', descuento:0:6);
writeln ('Valor de precio: ', precio:0:6);
writeln ('Valor de subtotal: ', subtotal:0:6);
writeln ('Valor de total: ', total:0:6);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.