• Lenguaje

    Pascal

  • Descripción

    Según las horas en la que se comprar un artículo obtienes un descuento:
    - Ropa es 16:30 a 18:00 PM = 12% | 18:00 a 21:30 PM = 8% | otros = 0%
    - Artesanía es 16:30 a 18:00 PM = 9% | 18:00 a 21:30 PM = 6% | otros = 0%
    - Libros es 16:30 a 18:00 PM = 7% | 18:00 a 21:30 PM = 4% | otros = 0%
    Mostrar monto total a pagar (incluyendo el 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
program DescuentoEnRopaArtesaniasYLibros;
uses crt;

var articulo, hora_de_compra, minuto_de_compra : integer;
var cantidad_de_articulos, costo_del_articulo, descuento, subtotal, total_a_pagar : real;
var total_descuento : real;
var tecla_repetir : char;
begin
    total_a_pagar := 0;
    total_descuento := 0;
    write ('Ingresa el valor de hora de compra: ');
    readln (hora_de_compra);
    write ('Ingresa el valor de minuto de compra: ');
    readln (minuto_de_compra);
    repeat
        clrscr;
        write ('Ingresa el valor de cantidad de articulos: ');
        readln (cantidad_de_articulos);
        write ('Ingresa el valor de costo del articulo: ');
        readln (costo_del_articulo);
        writeln ('Selecciona el valor de articulo.');
        writeln ('    1.- Ropa');
        writeln ('    2.- Artesan'#161'a');
        writeln ('    3.- Libros');
        write ('    : ');
        repeat
            readln (articulo);
            if (articulo<1) or (articulo>3) then
                write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
        until (articulo>=1) and (articulo<=3);
        descuento := 0;
        subtotal := costo_del_articulo*cantidad_de_articulos;
        if (articulo=1) and (((hora_de_compra=16) and (minuto_de_compra>=30)) or (hora_de_compra=17)) then
            begin
                descuento := subtotal*0.12;
            end;
        if (articulo=1) and ((hora_de_compra=18) or (hora_de_compra=19) or (hora_de_compra=20) or ((hora_de_compra=21) and (minuto_de_compra<=30))) then
            begin
                descuento := subtotal*0.08;
            end;
        if (articulo=2) and (((hora_de_compra=16) and (minuto_de_compra>=30)) or (hora_de_compra=17)) then
            begin
                descuento := subtotal*0.09;
            end;
        if (articulo=2) and ((hora_de_compra=18) or (hora_de_compra=19) or (hora_de_compra=20) or ((hora_de_compra=21) and (minuto_de_compra<=30))) then
            begin
                descuento := subtotal*0.06;
            end;
        if (articulo=3) and (((hora_de_compra=16) and (minuto_de_compra>=30)) or (hora_de_compra=17)) then
            begin
                descuento := subtotal*0.07;
            end;
        if (articulo=3) and ((hora_de_compra=18) or (hora_de_compra=19) or (hora_de_compra=20) or ((hora_de_compra=21) and (minuto_de_compra<=30))) then
            begin
                descuento := subtotal*0.04;
            end;
        total_a_pagar := total_a_pagar+subtotal;
        total_descuento := total_descuento+descuento;
        writeln ('Valor de descuento: ', descuento:0:6);
        writeln ('Valor de subtotal: ', subtotal: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');
    total_a_pagar := total_a_pagar-total_descuento;
    writeln ('Valor de total a pagar: ', total_a_pagar:0:6);
    writeln ('Valor de total descuento: ', total_descuento:0:6);
    write ('Presiona una tecla para terminar . . . ');
    readkey;
end.