• Lenguaje

    Pascal

  • Descripción

    Permita registrar la cantidad de pasajeros que pasan por un peaje en ómnibus, minivans y combis. Por cada vehículo se ingresará el tipo de vehículo y la cantidad de pasajeros y el turno (mañana, tarde y noche)
    Vehículo | Peaje
    Ómnibus | $15
    Minivan | $8
    Combi | $10
    - El total de peajes por turno.
    - El total de peajes por vehículo.
    - La cantidad de vehículos por tipo.
    - El promedio total de los peajes.

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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
program PasajerosQuePasanPorUnPeaje;
uses crt;

var peajes, tipo_de_vehiculo, turno, vehiculos_por_combi, vehiculos_por_minivan : integer;
var vehiculos_por_omnibus : integer;
var cantidad_de_pasajeros, peaje, peajes_de_combis, peajes_de_la_manana, peajes_de_la_noche : real;
var peajes_de_la_tarde, peajes_de_minivans, peajes_de_omnibus, promedio_de_peajes, total_de_pasajeros : real;
var total_de_peajes : real;
var tecla_repetir : char;
begin
    peajes := 0;
    vehiculos_por_combi := 0;
    vehiculos_por_minivan := 0;
    vehiculos_por_omnibus := 0;
    peajes_de_combis := 0;
    peajes_de_la_manana := 0;
    peajes_de_la_noche := 0;
    peajes_de_la_tarde := 0;
    peajes_de_minivans := 0;
    peajes_de_omnibus := 0;
    promedio_de_peajes := 0;
    total_de_pasajeros := 0;
    total_de_peajes := 0;
    repeat
        clrscr;
        write ('Ingresa el valor de cantidad de pasajeros: ');
        readln (cantidad_de_pasajeros);
        writeln ('Selecciona el valor de tipo de vehiculo.');
        writeln ('    1.- '#224'mnibus');
        writeln ('    2.- Minivan');
        writeln ('    3.- Combi');
        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);
        peaje := 0;
        if tipo_de_vehiculo=1 then
            begin
                peaje := 15*cantidad_de_pasajeros;
                peajes_de_omnibus := peajes_de_omnibus+peaje*cantidad_de_pasajeros;
                vehiculos_por_omnibus := vehiculos_por_omnibus+1;
            end;
        if tipo_de_vehiculo=2 then
            begin
                peaje := 8*cantidad_de_pasajeros;
                peajes_de_minivans := peajes_de_minivans+peaje*cantidad_de_pasajeros;
                vehiculos_por_minivan := vehiculos_por_minivan+1;
            end;
        if tipo_de_vehiculo=3 then
            begin
                peaje := 10*cantidad_de_pasajeros;
                peajes_de_combis := peajes_de_combis+peaje*cantidad_de_pasajeros;
                vehiculos_por_combi := vehiculos_por_combi+1;
            end;
        if turno=1 then
            begin
                peajes_de_la_manana := peajes_de_la_manana+peaje;
            end;
        if turno=2 then
            begin
                peajes_de_la_tarde := peajes_de_la_tarde+peaje;
            end;
        if turno=3 then
            begin
                peajes_de_la_noche := peajes_de_la_noche+peaje;
            end;
        total_de_peajes := total_de_peajes+peaje*cantidad_de_pasajeros;
        total_de_pasajeros := total_de_pasajeros+cantidad_de_pasajeros;
        peajes := peajes+1;
        writeln ('Valor de peaje: ', peaje: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');
    if peajes = 0 then
        promedio_de_peajes := 0
    else
        promedio_de_peajes := total_de_peajes/peajes;
    writeln ('Valor de peajes: ', peajes);
    writeln ('Valor de vehiculos por combi: ', vehiculos_por_combi);
    writeln ('Valor de vehiculos por minivan: ', vehiculos_por_minivan);
    writeln ('Valor de vehiculos por omnibus: ', vehiculos_por_omnibus);
    writeln ('Valor de peajes de combis: ', peajes_de_combis:0:6);
    writeln ('Valor de peajes de la manana: ', peajes_de_la_manana:0:6);
    writeln ('Valor de peajes de la noche: ', peajes_de_la_noche:0:6);
    writeln ('Valor de peajes de la tarde: ', peajes_de_la_tarde:0:6);
    writeln ('Valor de peajes de minivans: ', peajes_de_minivans:0:6);
    writeln ('Valor de peajes de omnibus: ', peajes_de_omnibus:0:6);
    writeln ('Valor de promedio de peajes: ', promedio_de_peajes:0:6);
    writeln ('Valor de total de pasajeros: ', total_de_pasajeros:0:6);
    writeln ('Valor de total de peajes: ', total_de_peajes:0:6);
    write ('Presiona una tecla para terminar . . . ');
    readkey;
end.