-
Lenguaje
Pascal
-
Descripción
Hamburguesas cuadradas Tío Billy ofrece hamburguesas sencillas, dobles y triples, las cuales tienen un costo de $20, $25 y $28 respectivamente. La empresa acepta tarjetas de crédito con un cargo de 5% sobre la compra. Suponiendo que los clientes adquieren sólo un tipo de hamburguesa, determine cuánto debe pagar una persona por N hamburguesas consumidas.
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
52
53
54
55
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
52
53
54
55
program HamburguesasCuadradasTioBilly;
uses crt;
var tipo_de_hamburguesa, tipo_de_pago : integer;
var N_hamburguesas_consumidas, cargo, pago : real;
begin
write ('Ingresa el valor de N hamburguesas consumidas: ');
readln (N_hamburguesas_consumidas);
writeln ('Selecciona el valor de tipo de hamburguesa.');
writeln (' 1.- sencillas');
writeln (' 2.- dobles');
writeln (' 3.- triples');
write (' : ');
repeat
readln (tipo_de_hamburguesa);
if (tipo_de_hamburguesa<1) or (tipo_de_hamburguesa>3) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (tipo_de_hamburguesa>=1) and (tipo_de_hamburguesa<=3);
writeln ('Selecciona el valor de tipo de pago.');
writeln (' 1.- efectivo');
writeln (' 2.- tarjeta');
write (' : ');
repeat
readln (tipo_de_pago);
if (tipo_de_pago<1) or (tipo_de_pago>2) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (tipo_de_pago>=1) and (tipo_de_pago<=2);
pago := 0;
if tipo_de_hamburguesa=1 then
begin
pago := N_hamburguesas_consumidas*20;
end;
if tipo_de_hamburguesa=2 then
begin
pago := N_hamburguesas_consumidas*25;
end;
if tipo_de_hamburguesa=3 then
begin
pago := N_hamburguesas_consumidas*28;
end;
if tipo_de_pago=2 then
begin
cargo := pago*0.05;
end
else
begin
cargo := 0;
end;
pago := pago+cargo;
writeln ('Valor de cargo: ', cargo:0:6);
writeln ('Valor de pago: ', pago:0:6);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var tipo_de_hamburguesa, tipo_de_pago : integer;
var N_hamburguesas_consumidas, cargo, pago : real;
begin
write ('Ingresa el valor de N hamburguesas consumidas: ');
readln (N_hamburguesas_consumidas);
writeln ('Selecciona el valor de tipo de hamburguesa.');
writeln (' 1.- sencillas');
writeln (' 2.- dobles');
writeln (' 3.- triples');
write (' : ');
repeat
readln (tipo_de_hamburguesa);
if (tipo_de_hamburguesa<1) or (tipo_de_hamburguesa>3) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (tipo_de_hamburguesa>=1) and (tipo_de_hamburguesa<=3);
writeln ('Selecciona el valor de tipo de pago.');
writeln (' 1.- efectivo');
writeln (' 2.- tarjeta');
write (' : ');
repeat
readln (tipo_de_pago);
if (tipo_de_pago<1) or (tipo_de_pago>2) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (tipo_de_pago>=1) and (tipo_de_pago<=2);
pago := 0;
if tipo_de_hamburguesa=1 then
begin
pago := N_hamburguesas_consumidas*20;
end;
if tipo_de_hamburguesa=2 then
begin
pago := N_hamburguesas_consumidas*25;
end;
if tipo_de_hamburguesa=3 then
begin
pago := N_hamburguesas_consumidas*28;
end;
if tipo_de_pago=2 then
begin
cargo := pago*0.05;
end
else
begin
cargo := 0;
end;
pago := pago+cargo;
writeln ('Valor de cargo: ', cargo:0:6);
writeln ('Valor de pago: ', pago:0:6);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.