-
Lenguaje
Pascal
-
Descripción
Una compañia de seguros ha reunido datos concernientes a todos los accidentes ocurridos durante el año. Los datos que se tienen de cada conductor involucrado son los siguientes:
- edad del conductor
- sexo
Obtener el porcentaje de conductores de sexo femenino.
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
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
program DatosDeAccidentes;
uses crt;
var cantidad_conductores, cantidad_femenino, sexo : integer;
var porcentaje : real;
var edad : string;
var tecla_repetir : char;
begin
cantidad_femenino := 0;
cantidad_conductores := 0;
porcentaje := 0;
repeat
clrscr;
write ('Ingresa el edad: ');
readln (edad);
writeln ('Selecciona el valor de sexo.');
writeln (' 1.- Femenino');
writeln (' 2.- Masculino');
write (' : ');
repeat
readln (sexo);
if (sexo<1) or (sexo>2) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (sexo>=1) and (sexo<=2);
if sexo=1 then
begin
cantidad_femenino := cantidad_femenino+1;
end;
cantidad_conductores := cantidad_conductores+1;
writeln ('Edad: ', edad);
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 cantidad_conductores = 0 then
porcentaje := 0
else
porcentaje := 100.0*cantidad_femenino/cantidad_conductores;
writeln ('Valor de cantidad femenino: ', cantidad_femenino);
writeln ('Valor de cantidad conductores: ', cantidad_conductores);
writeln ('Valor de porcentaje: ', porcentaje:0:6);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var cantidad_conductores, cantidad_femenino, sexo : integer;
var porcentaje : real;
var edad : string;
var tecla_repetir : char;
begin
cantidad_femenino := 0;
cantidad_conductores := 0;
porcentaje := 0;
repeat
clrscr;
write ('Ingresa el edad: ');
readln (edad);
writeln ('Selecciona el valor de sexo.');
writeln (' 1.- Femenino');
writeln (' 2.- Masculino');
write (' : ');
repeat
readln (sexo);
if (sexo<1) or (sexo>2) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (sexo>=1) and (sexo<=2);
if sexo=1 then
begin
cantidad_femenino := cantidad_femenino+1;
end;
cantidad_conductores := cantidad_conductores+1;
writeln ('Edad: ', edad);
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 cantidad_conductores = 0 then
porcentaje := 0
else
porcentaje := 100.0*cantidad_femenino/cantidad_conductores;
writeln ('Valor de cantidad femenino: ', cantidad_femenino);
writeln ('Valor de cantidad conductores: ', cantidad_conductores);
writeln ('Valor de porcentaje: ', porcentaje:0:6);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.