-
Lenguaje
Pascal
-
Descripción
En una carretera de cuota se pretende calcular el monto a pagar por los vehículos que circulan por dicha carretera, tomando como base lo siguiente:
a. Si el vehículo es de tipo "moto", la cuota es de $20, sin embargo, se le aplicará un descuento del 4%.
b. Si el vehículo es de tipo "coche", la cuota es de $35, sin embargo, se le aplicará un descuento del 5%.
c. Si el vehículo es de tipo "carga", la cuota es de $50, sin embargo, se le aplicará un descuento del 6%.
d. Pero si el vehículo es de tipo "escolar", pasa sin pagar cuota alguna.
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
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
program CuotaEnUnaCarretera;
uses crt;
var tipo_de_vehiculo : integer;
var cuota, descuento, monto_a_pagar : real;
begin
cuota := 0;
descuento := 0;
writeln ('Selecciona el valor de tipo de vehiculo.');
writeln (' 1.- Moto');
writeln (' 2.- Coche');
writeln (' 3.- Carga');
writeln (' 4.- Escolar');
write (' : ');
repeat
readln (tipo_de_vehiculo);
if (tipo_de_vehiculo<1) or (tipo_de_vehiculo>4) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (tipo_de_vehiculo>=1) and (tipo_de_vehiculo<=4);
if tipo_de_vehiculo=1 then
begin
cuota := 20;
descuento := cuota*0.04;
end;
if tipo_de_vehiculo=2 then
begin
cuota := 35;
descuento := cuota*0.05;
end;
if tipo_de_vehiculo=3 then
begin
cuota := 50;
descuento := cuota*0.06;
end;
monto_a_pagar := cuota-descuento;
writeln ('Valor de cuota: ', cuota:0:6);
writeln ('Valor de descuento: ', descuento:0:6);
writeln ('Valor de monto a pagar: ', monto_a_pagar:0:6);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var tipo_de_vehiculo : integer;
var cuota, descuento, monto_a_pagar : real;
begin
cuota := 0;
descuento := 0;
writeln ('Selecciona el valor de tipo de vehiculo.');
writeln (' 1.- Moto');
writeln (' 2.- Coche');
writeln (' 3.- Carga');
writeln (' 4.- Escolar');
write (' : ');
repeat
readln (tipo_de_vehiculo);
if (tipo_de_vehiculo<1) or (tipo_de_vehiculo>4) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (tipo_de_vehiculo>=1) and (tipo_de_vehiculo<=4);
if tipo_de_vehiculo=1 then
begin
cuota := 20;
descuento := cuota*0.04;
end;
if tipo_de_vehiculo=2 then
begin
cuota := 35;
descuento := cuota*0.05;
end;
if tipo_de_vehiculo=3 then
begin
cuota := 50;
descuento := cuota*0.06;
end;
monto_a_pagar := cuota-descuento;
writeln ('Valor de cuota: ', cuota:0:6);
writeln ('Valor de descuento: ', descuento:0:6);
writeln ('Valor de monto a pagar: ', monto_a_pagar:0:6);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.