• Lenguaje

    Pascal

  • Descripción

    Registrar de vehículos (cantidad desconocida) que pasan por un peaje en autos, motocicletas y camiones. Por cada vehículo se ingresará el tipo de vehículo y el turno (mañana, tarde y noche).

    Vehículo | Peaje
    Auto | $5
    Motocicleta | $3
    Camión | $12

    Mostrar un reporte con:
    - El total de peajes por turno.
    - El total de peajes por vehículo.
    - La cantidad de vehículos por tipo.

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
73
74
75
76
77
78
79
80
81
82
83
84
program RegistroDeVehiculos;
uses crt;

var autos, camiones, motocicletas, peajes_auto, peajes_camion : integer;
var peajes_manana, peajes_motocicleta, peajes_noche, peajes_tarde, tipo_de_vehiculo : integer;
var turno : integer;
var tecla_repetir : char;
begin
    autos := 0;
    camiones := 0;
    motocicletas := 0;
    peajes_auto := 0;
    peajes_camion := 0;
    peajes_manana := 0;
    peajes_motocicleta := 0;
    peajes_noche := 0;
    peajes_tarde := 0;
    repeat
        clrscr;
        writeln ('Selecciona el valor de tipo de vehiculo.');
        writeln ('    1.- Auto');
        writeln ('    2.- Motocicleta');
        writeln ('    3.- Cami'#162'n');
        write ('    : ');
        repeat
            readln (tipo_de_vehiculo);
            if (tipo_de_vehiculo<1) or (tipo_de_vehiculo>3) then
                write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
        until (tipo_de_vehiculo>=1) and (tipo_de_vehiculo<=3);
        writeln ('Selecciona el valor de turno.');
        writeln ('    1.- ma'#164'ana');
        writeln ('    2.- tarde');
        writeln ('    3.- noche');
        write ('    : ');
        repeat
            readln (turno);
            if (turno<1) or (turno>3) then
                write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
        until (turno>=1) and (turno<=3);
        if turno=1 then
            begin
                peajes_manana := peajes_manana+1;
            end;
        if turno=2 then
            begin
                peajes_tarde := peajes_tarde+1;
            end;
        if turno=3 then
            begin
                peajes_noche := peajes_noche+1;
            end;
        if tipo_de_vehiculo=1 then
            begin
                peajes_auto := peajes_auto+1;
                autos := autos+1;
            end;
        if tipo_de_vehiculo=2 then
            begin
                peajes_motocicleta := peajes_motocicleta+1;
                motocicletas := motocicletas+1;
            end;
        if tipo_de_vehiculo=3 then
            begin
                peajes_camion := peajes_camion+1;
                camiones := camiones+1;
            end;
        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');
    writeln ('Valor de autos: ', autos);
    writeln ('Valor de camiones: ', camiones);
    writeln ('Valor de motocicletas: ', motocicletas);
    writeln ('Valor de peajes auto: ', peajes_auto);
    writeln ('Valor de peajes camion: ', peajes_camion);
    writeln ('Valor de peajes manana: ', peajes_manana);
    writeln ('Valor de peajes motocicleta: ', peajes_motocicleta);
    writeln ('Valor de peajes noche: ', peajes_noche);
    writeln ('Valor de peajes tarde: ', peajes_tarde);
    write ('Presiona una tecla para terminar . . . ');
    readkey;
end.