Pascal/Turbo Pascal - Arreglos en una Encuesta

 
Vista:
sin imagen de perfil

Arreglos en una Encuesta

Publicado por Erick (6 intervenciones) el 02/08/2014 03:32:32
Quien podría ayudarme con este ejercicio de pascal por favor... El ejercicio dice así:

Se realiza una encuesta a un numero determinado de personas (N). En la encuesta se pregunta por edad, sexo y estado civil. Escriba un programa que determine:

a) La edad promedio por sexo.
b) El porcentaje de hombres casados.
c) El porcentaje de mujeres casadas.
d) El porcentaje de hombres que poseen una edad entre 25 y 40 años.
e) El porcentaje de mujeres que poseen una edad entre 20 y 30 años.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Arreglos en una Encuesta

Publicado por ramon (39 intervenciones) el 04/08/2014 00:51:03
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
109
110
{A ver si esto te ayuda}
 
program encuesta;
  uses
     crt;
   const
      personas = 10;
   type
     datos = record
         edad : integer;
         sexo : char;
         estado : char;
       end;
 
  var
    encu : array[1..personas] of datos;
    cont : integer;
    casadm, casadf, edm, edf : real;
    mi, di, medad, fedad : real;
    tecla : char;
 
   procedure entrada(var n : integer);
   begin
      clrscr;
      writeln(' ***** Entrada Datos Encuesta *****');
      writeln;
      with encu[n] do
      begin
      write('   Edad : ');
      readln(edad);
      write('   Sexo [ M / F ] : ');
      repeat
          sexo := upcase(readkey);
      until sexo in['M','F'];
      write(sexo);
      writeln;
      write('  Casado [ C / S ] : ');
      repeat
          estado := upcase(readkey);
      until estado in['C','S'];
      write(estado);
     end;
       n := n + 1;
       if n > personas then
       n := personas;
   end;
 
   procedure tomaderesultados;
   var
     ni, c : integer;
   begin
      if cont < personas then
      ni := cont - 1
    else
      ni := cont;
      medad := 0;
      fedad := 0;
      casadm := 0;
      casadf := 0;
      edm := 0;
      edf := 0;
      mi := 0;
      di := 0;
      for c := 1 to ni do
      begin
         if (encu[c].sexo = 'M') and (encu[c].edad in[26..39]) then
         medad := medad + 1;
         if (encu[c].sexo = 'F') and (encu[c].edad in[20..30]) then
         fedad := fedad + 1;
         if (encu[c].sexo = 'M') and (encu[c].estado = 'C') then
         casadm := casadm + 1;
         if (encu[c].sexo = 'F') and (encu[c].estado = 'C') then
         casadf := casadf + 1;
         if encu[c].sexo = 'M' then
         begin
         edm := edm + encu[c].edad;
         mi := mi + 1;
         end;
         if encu[c].sexo = 'F' then
         begin
         edf := edf + encu[c].edad;
         di := di + 1;
         end;
      end;
   end;
 
 
   begin
      cont := 1;
     repeat
      entrada(cont);
      writeln;
      writeln('  Desea Entrar Mas Datos [ S / N ]');
      repeat
      tecla := upcase(readkey);
      until tecla in['S','N'];
      clrscr;
    until tecla = 'N';
    tomaderesultados;
    clrscr;
    if (edm > 0) and (mi > 0) then
    writeln('  Edad Promedio Masculino  : ',edm / mi:0:2);
    if (edf > 0) and (di > 0) then
    writeln('  Edad Promedio Femenina   : ',edf / di:0:2);
    writeln('  Proc. Masculino Casados  : ',casadm / 100:0:2);
    writeln('  Proc. Femenina Casadas   : ',casadf / 100:0:2);
    writeln('  Proc. Edad Femenina entre 20 y 30 : ',fedad / 100:0:2);
    writeln('  Proc. Edad Masculino entre 26 y 39 : ',medad / 100:0:2);
    readkey;
   end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar