-
Lenguaje
Pascal
-
Descripción
Una farmacia ofrece un descuento del 3% del valor de la compra si el pago se efectúa al contado, y se el pago es con tarjeta se le recarga un 5% del valor de compra. Calcular el descuento, recargo y el total a pagar.
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
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
program DescuentoYRecargoEnUnaFarmacia;
uses crt;
var tipo_de_pago : integer;
var compra, descuento, recargo, total : real;
begin
write ('Ingresa el valor de compra: ');
readln (compra);
writeln ('Selecciona el valor de tipo de pago.');
writeln (' 1.- Al contado');
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);
if tipo_de_pago=1 then
begin
descuento := compra*0.03;
recargo := 0;
end
else
begin
descuento := 0;
recargo := compra*0.05;
end;
total := compra-descuento+recargo;
writeln ('Valor de descuento: ', descuento:0:6);
writeln ('Valor de recargo: ', recargo:0:6);
writeln ('Valor de total: ', total:0:6);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var tipo_de_pago : integer;
var compra, descuento, recargo, total : real;
begin
write ('Ingresa el valor de compra: ');
readln (compra);
writeln ('Selecciona el valor de tipo de pago.');
writeln (' 1.- Al contado');
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);
if tipo_de_pago=1 then
begin
descuento := compra*0.03;
recargo := 0;
end
else
begin
descuento := 0;
recargo := compra*0.05;
end;
total := compra-descuento+recargo;
writeln ('Valor de descuento: ', descuento:0:6);
writeln ('Valor de recargo: ', recargo:0:6);
writeln ('Valor de total: ', total:0:6);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.