• Lenguaje

    Pascal

  • Descripción

    En una librería se venden artículos con las siguientes condiciones:
    - Sí el cliente es de tipo 1 se le descuenta 30%.
    - Sí el cliente es de tipo 2 se le descuenta 20%.
    - Sí el cliente es de tipo 3 se le descuenta 10%.
    Escribir un algoritmo que lea el nombre del cliente, tipo de cliente, precio. Calcule el pago final.

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
program DescuentosEnUnaLibreria;
uses crt;

var tipo : integer;
var descuento, pago_final, precio : real;
begin
    write ('Ingresa el valor de precio: ');
    readln (precio);
    writeln ('Selecciona el valor de tipo.');
    writeln ('    1.- uno');
    writeln ('    2.- dos');
    writeln ('    3.- tres');
    write ('    : ');
    repeat
        readln (tipo);
        if (tipo<1) or (tipo>3) then
            write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
    until (tipo>=1) and (tipo<=3);
    descuento := 0;
    if tipo=1 then
        begin
            descuento := precio*0.3;
        end;
    if tipo=2 then
        begin
            descuento := precio*0.2;
        end;
    if tipo=3 then
        begin
            descuento := precio*0.1;
        end;
    pago_final := precio-descuento;
    writeln ('Valor de descuento: ', descuento:0:6);
    writeln ('Valor de pago final: ', pago_final:0:6);
    writeln;
    write ('Presiona una tecla para terminar . . . ');
    readkey;
end.