-
Lenguaje
Pascal
-
Descripción
Una librería vende libros bajo las siguientes condiciones: si el cliente es tipo 1 (docente) se le descuenta el 30%, si el cliente es tipo 2 (estudiante) se le descuenta el 20% y si el cliente es tipo 3 se le descuenta el 10%. Cuando el cliente realiza la compra, se deben ingresar: el nombre del cliente, tipo de cliente (1,2,3), la cantidad de libros y el costo del libro. Si la cantidad de libros solicitada es mayor de 5 se hace un descuento adicional de 4%, en caso de ser mayor de 10 unidades se hace un descuento adicional de 8%. Hacer un algoritmo para que muestre: nombre del cliente, total a pagar, descuento y neto 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
program LibrosConDescuentos;
uses crt;
var tipo_de_cliente : integer;
var cantidad_de_libros, costo_del_libro, descuento, neto_a_pagar, total_a_pagar : real;
var nombre_del_cliente : string;
begin
write ('Ingresa el nombre del cliente: ');
readln (nombre_del_cliente);
write ('Ingresa el valor de cantidad de libros: ');
readln (cantidad_de_libros);
write ('Ingresa el valor de costo del libro: ');
readln (costo_del_libro);
neto_a_pagar := cantidad_de_libros*costo_del_libro;
descuento := 0;
writeln ('Selecciona el valor de tipo de cliente.');
writeln (' 1.- docente');
writeln (' 2.- estudiante');
writeln (' 3.- otro');
write (' : ');
repeat
readln (tipo_de_cliente);
if (tipo_de_cliente<1) or (tipo_de_cliente>3) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (tipo_de_cliente>=1) and (tipo_de_cliente<=3);
if tipo_de_cliente=1 then
begin
descuento := neto_a_pagar*0.3;
end;
if tipo_de_cliente=2 then
begin
descuento := neto_a_pagar*0.2;
end;
if tipo_de_cliente=3 then
begin
descuento := neto_a_pagar*0.1;
end;
if (cantidad_de_libros>5) and (cantidad_de_libros<=10) then
begin
descuento := descuento*0.04;
end;
if cantidad_de_libros>10 then
begin
descuento := descuento*0.08;
end;
total_a_pagar := neto_a_pagar-descuento;
writeln ('Nombre del cliente: ', nombre_del_cliente);
writeln ('Valor de descuento: ', descuento:0:6);
writeln ('Valor de neto a pagar: ', neto_a_pagar:0:6);
writeln ('Valor de total a pagar: ', total_a_pagar:0:6);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var tipo_de_cliente : integer;
var cantidad_de_libros, costo_del_libro, descuento, neto_a_pagar, total_a_pagar : real;
var nombre_del_cliente : string;
begin
write ('Ingresa el nombre del cliente: ');
readln (nombre_del_cliente);
write ('Ingresa el valor de cantidad de libros: ');
readln (cantidad_de_libros);
write ('Ingresa el valor de costo del libro: ');
readln (costo_del_libro);
neto_a_pagar := cantidad_de_libros*costo_del_libro;
descuento := 0;
writeln ('Selecciona el valor de tipo de cliente.');
writeln (' 1.- docente');
writeln (' 2.- estudiante');
writeln (' 3.- otro');
write (' : ');
repeat
readln (tipo_de_cliente);
if (tipo_de_cliente<1) or (tipo_de_cliente>3) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (tipo_de_cliente>=1) and (tipo_de_cliente<=3);
if tipo_de_cliente=1 then
begin
descuento := neto_a_pagar*0.3;
end;
if tipo_de_cliente=2 then
begin
descuento := neto_a_pagar*0.2;
end;
if tipo_de_cliente=3 then
begin
descuento := neto_a_pagar*0.1;
end;
if (cantidad_de_libros>5) and (cantidad_de_libros<=10) then
begin
descuento := descuento*0.04;
end;
if cantidad_de_libros>10 then
begin
descuento := descuento*0.08;
end;
total_a_pagar := neto_a_pagar-descuento;
writeln ('Nombre del cliente: ', nombre_del_cliente);
writeln ('Valor de descuento: ', descuento:0:6);
writeln ('Valor de neto a pagar: ', neto_a_pagar:0:6);
writeln ('Valor de total a pagar: ', total_a_pagar:0:6);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.