-
Lenguaje
Pascal
-
Descripción
Una librería muy famosa ofrece descuentos dependiendo de la editorial y del tipo de comprador, según la siguiente tabla:
EDITORIAL | ESTUDIANTE | PÚBLICO EN GENERAL
San Marcos | 25% | 10%
Coveñas - 30% | 13%
Otros | 35% | 16%
Construya un algoritmo que ingrese el importe de la compra, el tipo de comprador y la editorial, muestre el descuento, importante total a pagar. Asuma que el monto total de la compra es de una misma editora.
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
56
57
58
59
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
56
57
58
59
program DescuentosEnUnaLibreriaFamosa;
uses crt;
var editorial, tipo_de_comprador : integer;
var descuento, importante_total_a_pagar, importe_de_la_compra : real;
begin
write ('Ingresa el valor de importe de la compra: ');
readln (importe_de_la_compra);
writeln ('Selecciona el valor de editorial.');
writeln (' 1.- San Marcos');
writeln (' 2.- Cove'#164'as');
writeln (' 3.- Otros');
write (' : ');
repeat
readln (editorial);
if (editorial<1) or (editorial>3) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (editorial>=1) and (editorial<=3);
writeln ('Selecciona el valor de tipo de comprador.');
writeln (' 1.- Estudiante');
writeln (' 2.- P'#163'blico en general');
write (' : ');
repeat
readln (tipo_de_comprador);
if (tipo_de_comprador<1) or (tipo_de_comprador>2) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (tipo_de_comprador>=1) and (tipo_de_comprador<=2);
descuento := 0;
if (editorial=1) and (tipo_de_comprador=1) then
begin
descuento := importe_de_la_compra*0.25;
end;
if (editorial=1) and (tipo_de_comprador=2) then
begin
descuento := importe_de_la_compra*0.1;
end;
if (editorial=2) and (tipo_de_comprador=1) then
begin
descuento := importe_de_la_compra*0.3;
end;
if (editorial=2) and (tipo_de_comprador=2) then
begin
descuento := importe_de_la_compra*0.13;
end;
if (editorial=3) and (tipo_de_comprador=1) then
begin
descuento := importe_de_la_compra*0.35;
end;
if (editorial=3) and (tipo_de_comprador=2) then
begin
descuento := importe_de_la_compra*0.16;
end;
importante_total_a_pagar := importe_de_la_compra-descuento;
writeln ('Valor de descuento: ', descuento:0:6);
writeln ('Valor de importante total a pagar: ', importante_total_a_pagar:0:6);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var editorial, tipo_de_comprador : integer;
var descuento, importante_total_a_pagar, importe_de_la_compra : real;
begin
write ('Ingresa el valor de importe de la compra: ');
readln (importe_de_la_compra);
writeln ('Selecciona el valor de editorial.');
writeln (' 1.- San Marcos');
writeln (' 2.- Cove'#164'as');
writeln (' 3.- Otros');
write (' : ');
repeat
readln (editorial);
if (editorial<1) or (editorial>3) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (editorial>=1) and (editorial<=3);
writeln ('Selecciona el valor de tipo de comprador.');
writeln (' 1.- Estudiante');
writeln (' 2.- P'#163'blico en general');
write (' : ');
repeat
readln (tipo_de_comprador);
if (tipo_de_comprador<1) or (tipo_de_comprador>2) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (tipo_de_comprador>=1) and (tipo_de_comprador<=2);
descuento := 0;
if (editorial=1) and (tipo_de_comprador=1) then
begin
descuento := importe_de_la_compra*0.25;
end;
if (editorial=1) and (tipo_de_comprador=2) then
begin
descuento := importe_de_la_compra*0.1;
end;
if (editorial=2) and (tipo_de_comprador=1) then
begin
descuento := importe_de_la_compra*0.3;
end;
if (editorial=2) and (tipo_de_comprador=2) then
begin
descuento := importe_de_la_compra*0.13;
end;
if (editorial=3) and (tipo_de_comprador=1) then
begin
descuento := importe_de_la_compra*0.35;
end;
if (editorial=3) and (tipo_de_comprador=2) then
begin
descuento := importe_de_la_compra*0.16;
end;
importante_total_a_pagar := importe_de_la_compra-descuento;
writeln ('Valor de descuento: ', descuento:0:6);
writeln ('Valor de importante total a pagar: ', importante_total_a_pagar:0:6);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.