-
Lenguaje
Pascal
-
Descripción
Una compañía de viajes cuenta con tres tipos de autobuses (A, B y C). Cada uno tiene un precio por kilómetro recorrido por persona. Los costos respectivos son $2.0, $2.5 y $3.0. Se requiere determinar el costo total y por persona del viaje considerando que cuando éste se presupuesta debe haber un mínimo de 20 personas, de lo contrario el cobro se realiza con base en este número límite.
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
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
program CompaniaDeViajes2;
uses crt;
var tipo_de_autobus : integer;
var costo_por_persona, costo_total, numero_de_personas : real;
var tecla_repetir : char;
begin
repeat
clrscr;
write ('Ingresa el valor de numero de personas: ');
readln (numero_de_personas);
costo_por_persona := 0;
costo_total := 0;
writeln ('Selecciona el valor de tipo de autobus.');
writeln (' 1.- A');
writeln (' 2.- B');
writeln (' 3.- C');
write (' : ');
repeat
readln (tipo_de_autobus);
if (tipo_de_autobus<1) or (tipo_de_autobus>3) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (tipo_de_autobus>=1) and (tipo_de_autobus<=3);
if tipo_de_autobus=1 then
begin
costo_por_persona := 2;
end;
if tipo_de_autobus=2 then
begin
costo_por_persona := 2.5;
end;
if tipo_de_autobus=3 then
begin
costo_por_persona := 3;
end;
if numero_de_personas<20 then
begin
costo_total := costo_por_persona*20;
costo_por_persona := costo_total/numero_de_personas;
end
else
begin
costo_total := costo_por_persona*numero_de_personas;
end;
writeln ('Valor de costo por persona: ', costo_por_persona:0:6);
writeln ('Valor de costo total: ', costo_total: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');
end.
uses crt;
var tipo_de_autobus : integer;
var costo_por_persona, costo_total, numero_de_personas : real;
var tecla_repetir : char;
begin
repeat
clrscr;
write ('Ingresa el valor de numero de personas: ');
readln (numero_de_personas);
costo_por_persona := 0;
costo_total := 0;
writeln ('Selecciona el valor de tipo de autobus.');
writeln (' 1.- A');
writeln (' 2.- B');
writeln (' 3.- C');
write (' : ');
repeat
readln (tipo_de_autobus);
if (tipo_de_autobus<1) or (tipo_de_autobus>3) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (tipo_de_autobus>=1) and (tipo_de_autobus<=3);
if tipo_de_autobus=1 then
begin
costo_por_persona := 2;
end;
if tipo_de_autobus=2 then
begin
costo_por_persona := 2.5;
end;
if tipo_de_autobus=3 then
begin
costo_por_persona := 3;
end;
if numero_de_personas<20 then
begin
costo_total := costo_por_persona*20;
costo_por_persona := costo_total/numero_de_personas;
end
else
begin
costo_total := costo_por_persona*numero_de_personas;
end;
writeln ('Valor de costo por persona: ', costo_por_persona:0:6);
writeln ('Valor de costo total: ', costo_total: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');
end.