• Lenguaje

    Pascal

  • Descripción

    Las tarifas de una autopista dependen del tipo de vehículo (camión o automóvil) que desee utilizarla, del número de pasajero que lleve y de la hora del día:
    - En las horas de alta congestión los automoviles con 3 pasajeros o más no pagan peaje, y con menos de 3 pasajeros pagan $2.000; en baja congestión pagan $1.500 independientemente del número de pasajeros.
    - Los camiones pagan $3.500 en las horas baja congestión y $5.250 en las de alta, independientemente del número de pasajeros.
    Escriba un algoritmo que leyendo del tipo de vehículo, el tipo de congestión y el número de pasajeros, calcule la tarifa que le debe cobra a un vehículo.

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

var numero_de_pasajeros, tarifa, tipo_de_congestion, tipo_de_vehiculo : integer;
begin
    write ('Ingresa el valor de numero de pasajeros: ');
    readln (numero_de_pasajeros);
    tarifa := 0;
    writeln ('Selecciona el valor de tipo de vehiculo.');
    writeln ('    1.- Cami'#162'n');
    writeln ('    2.- Autom'#162'vil');
    write ('    : ');
    repeat
        readln (tipo_de_vehiculo);
        if (tipo_de_vehiculo<1) or (tipo_de_vehiculo>2) then
            write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
    until (tipo_de_vehiculo>=1) and (tipo_de_vehiculo<=2);
    writeln ('Selecciona el valor de tipo de congestion.');
    writeln ('    1.- Alta');
    writeln ('    2.- Baja');
    write ('    : ');
    repeat
        readln (tipo_de_congestion);
        if (tipo_de_congestion<1) or (tipo_de_congestion>2) then
            write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
    until (tipo_de_congestion>=1) and (tipo_de_congestion<=2);
    if (tipo_de_vehiculo=2) and (tipo_de_congestion=1) and (numero_de_pasajeros<3) then
        begin
            tarifa := 2000;
        end;
    if (tipo_de_vehiculo=2) and (tipo_de_congestion=2) then
        begin
            tarifa := 1500;
        end;
    if (tipo_de_vehiculo=1) and (tipo_de_congestion=2) then
        begin
            tarifa := 3500;
        end;
    if (tipo_de_vehiculo=1) and (tipo_de_congestion=1) then
        begin
            tarifa := 5250;
        end;
    writeln ('Valor de tarifa: ', tarifa);
    writeln;
    write ('Presiona una tecla para terminar . . . ');
    readkey;
end.