-
Lenguaje
Pascal
-
Descripción
Un restaurante vende dos tipos de comidas, servidas a 4.50 y para llevar a 6.00. Realice un algoritmo que teniendo como datos por cada cliente su nombre, tipo de comida y cantidad a comprar, calcule y de cómo salida el nombre y el neto a pagar por cada cliente, tomando en cuenta que el restaurante da una rebaja del 15% por cada compra que exceda de los 4 comidas.
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
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
program ComidasServidasYParaLlevar;
uses crt;
var tipo_de_comida : integer;
var cantidad_a_comprar, neto_a_pagar, rebaja, subtotal : real;
var nombre : string;
var tecla_repetir : char;
begin
repeat
clrscr;
write ('Ingresa el nombre: ');
readln (nombre);
write ('Ingresa el valor de cantidad a comprar: ');
readln (cantidad_a_comprar);
writeln ('Selecciona el valor de tipo de comida.');
writeln (' 1.- servidas');
writeln (' 2.- para llevar');
write (' : ');
repeat
readln (tipo_de_comida);
if (tipo_de_comida<1) or (tipo_de_comida>2) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (tipo_de_comida>=1) and (tipo_de_comida<=2);
if tipo_de_comida=1 then
begin
subtotal := 4.5*cantidad_a_comprar;
end
else
begin
subtotal := 6.0*cantidad_a_comprar;
end;
if cantidad_a_comprar>4 then
begin
rebaja := subtotal*0.15;
end
else
begin
rebaja := 0;
end;
neto_a_pagar := subtotal-rebaja;
writeln ('Nombre: ', nombre);
writeln ('Valor de neto a pagar: ', neto_a_pagar:0:6);
writeln ('Valor de rebaja: ', rebaja:0:6);
writeln ('Valor de subtotal: ', subtotal:0:6);
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');
end.
uses crt;
var tipo_de_comida : integer;
var cantidad_a_comprar, neto_a_pagar, rebaja, subtotal : real;
var nombre : string;
var tecla_repetir : char;
begin
repeat
clrscr;
write ('Ingresa el nombre: ');
readln (nombre);
write ('Ingresa el valor de cantidad a comprar: ');
readln (cantidad_a_comprar);
writeln ('Selecciona el valor de tipo de comida.');
writeln (' 1.- servidas');
writeln (' 2.- para llevar');
write (' : ');
repeat
readln (tipo_de_comida);
if (tipo_de_comida<1) or (tipo_de_comida>2) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (tipo_de_comida>=1) and (tipo_de_comida<=2);
if tipo_de_comida=1 then
begin
subtotal := 4.5*cantidad_a_comprar;
end
else
begin
subtotal := 6.0*cantidad_a_comprar;
end;
if cantidad_a_comprar>4 then
begin
rebaja := subtotal*0.15;
end
else
begin
rebaja := 0;
end;
neto_a_pagar := subtotal-rebaja;
writeln ('Nombre: ', nombre);
writeln ('Valor de neto a pagar: ', neto_a_pagar:0:6);
writeln ('Valor de rebaja: ', rebaja:0:6);
writeln ('Valor de subtotal: ', subtotal:0:6);
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');
end.