-
Lenguaje
Pascal
-
Descripción
En una tienda de descuento las personas que van a pagar el importe de su compra, llegan a la caja y sacan una bolita de color que les dirá qué descuento tendrán sobre el total de su compra. Determinar la cantidad que pagará cada cliente desde que la tienda abre hasta que cierra. Se sabe que si la bolita es roja, el cliente obtendrá un 40% de descuento; si es amarilla un 25% y si es blanca no obtendrá descuento.
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
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
program DescuentoPorBolitaRojaAmarillaBlanca;
uses crt;
var bolita : integer;
var cantidad_a_pagar, descuento, importe_de_la_compra : real;
var tecla_repetir : char;
begin
randomize;
repeat
clrscr;
write ('Ingresa el valor de importe de la compra: ');
readln (importe_de_la_compra);
descuento := 0;
bolita := random(3);
if bolita=0 then
begin
descuento := importe_de_la_compra*0.4;
writeln ('Bolita roja');
end;
if bolita=1 then
begin
descuento := importe_de_la_compra*0.25;
writeln ('Bolita amarilla');
end;
if bolita=2 then
begin
writeln ('Bolita blanca');
end;
cantidad_a_pagar := importe_de_la_compra-descuento;
writeln ('Valor de bolita: ', bolita:0:6);
writeln ('Valor de cantidad a pagar: ', cantidad_a_pagar:0:6);
writeln ('Valor de descuento: ', descuento: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 bolita : integer;
var cantidad_a_pagar, descuento, importe_de_la_compra : real;
var tecla_repetir : char;
begin
randomize;
repeat
clrscr;
write ('Ingresa el valor de importe de la compra: ');
readln (importe_de_la_compra);
descuento := 0;
bolita := random(3);
if bolita=0 then
begin
descuento := importe_de_la_compra*0.4;
writeln ('Bolita roja');
end;
if bolita=1 then
begin
descuento := importe_de_la_compra*0.25;
writeln ('Bolita amarilla');
end;
if bolita=2 then
begin
writeln ('Bolita blanca');
end;
cantidad_a_pagar := importe_de_la_compra-descuento;
writeln ('Valor de bolita: ', bolita:0:6);
writeln ('Valor de cantidad a pagar: ', cantidad_a_pagar:0:6);
writeln ('Valor de descuento: ', descuento: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.