Pascal/Turbo Pascal - Ejercicio de archivos (Tengo final ayuda) - Pascal

 
Vista:
Imágen de perfil de Facu

Ejercicio de archivos (Tengo final ayuda) - Pascal

Publicado por Facu (2 intervenciones) el 16/12/2015 07:07:34
Sinceramente me cuesta demasiado pascal. y tengo que rendir un final en unas horas y no encuentro ningun ejercicio completo y sin errores que me pueda ayudar.

El ejercicio que tengo como modelo de final es el siguiente:

Desarrollar un programa en pascal que permita crear y cargar un archivo de alumos para llevar un control de las notas de sus examenes parcials de la asignatura programacion 1. La estructura de los registros sera la siguiente:Nro_DNI, Apellido, Nombre, NP1, NP2:

a) Mediante un procedimiento, al que debera llamar ListadoAprobados, mostrar por pantalla el listado de los alumnos que hayan regularizado la materia, para ello, el promedio de ambas notas dbera ser igual o mayor a 7.

b) Permitir, al usuario realizar la busqueda de alumnos ingresando el numero de DNI. Mostrar los datos encontrados, en caso contrario, el siguiente mensaje "No se encuentran datos del Alumno".


Muy importante. Todo esto se graba en un archivo de datos que despues se lee. Creo que se hacia con un archivo.dat pero no me acuerdo.

Necesito ayuda urgente, por favor...
Desde ya muchas gracias
Facundo
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

Ejercicio de archivos (Tengo final ayuda) - Pascal

Publicado por ramon (2158 intervenciones) el 18/12/2015 11:45:00
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
{Mira Esto}
 
 program alumnos;
  uses
    crt;
  const
     archivo = 'archivo.dat';
  type
    elalumnos = record
           Nro_DNI : longint;
          Apellido : string[80];
            Nombre : string[80];
           NP1,NP2 : real;
             end;
 
   var
     f : file of elalumnos;
     alum : elalumnos;
 
 
 
    function existearchivo : boolean;
    begin
       assign(f,archivo);
     {$I-} reset(f); {$I+}
     if ioresult <> 0 then
     existearchivo := false
   else
     begin
        existearchivo := true;
     end;
    end;
 
   procedure entradadatos;
   var
     tec : char;
   begin
      clrscr;
      writeln('    ****** Entrada Datos Alumno Nuevo ******');
      writeln;
      write('    Entre Numero DNI : ');
      readln(alum.Nro_DNI);
      write('    Entre Apellido   : ');
      readln(alum.Apellido);
      write('    Entre Nombre     : ');
      readln(alum.Nombre);
      write('    Entre Nota 1     : ');
      readln(alum.NP1);
      write('    Entre Nota 2     : ');
      readln(alum.NP2);
      writeln;
      writeln('   Se Guardar Los Datos ');
      writeln;
      writeln('   Datos Correctos [S/N]');
      repeat
          tec := upcase(readkey);
      until tec in['S','N'];
      if tec = 'S' then
      begin
        if existearchivo = true then
        begin
           seek(f,filesize(f));
           write(f,alum);
           close(f);
        end
      else
          begin
             rewrite(f);
             seek(f,0);
             write(f,alum);
             close(f);
          end;
      end;
   end;
 
   procedure ListadoAprobados;
   var
     k : longint;
   begin
      if existearchivo = true then
      begin
         writeln('    Los Aprovadis Son ');
         writeln;
         for k := 0 to filesize(f) - 1 do
         begin
            seek(f,k);
            read(f,alum);
            if ((alum.np1 + alum.np2) / 2) >= 7 then
            writeln('   Aprovado : ',alum.nombre,'  ',alum.apellido,'  ',
                        ((alum.np1 + alum.np2) / 2):0:2);
         end;
           close(f);
           readkey;
      end
   else
       begin
         writeln('   Error De Archivo O No Existe Pulse Una Tecla');
         readkey;
       end;
   end;
 
   procedure busqueda_alumno;
   var
     ddn : longint;
     tt, vus : longint;
     encon : boolean;
   begin
      if existearchivo = true then
      begin
        writeln('   Buscar Un Alumno ');
        writeln;
        write('     Entre Num DNI : ');
        readln(ddn);
        encon := false;
        for vus := 0 to filesize(f) - 1 do
        begin
           seek(f,vus);
           read(f,alum);
           if alum.Nro_DNI = ddn then
           begin
              encon := true;
              break;
           end;
        end;
        if encon = true then
        writeln('   ',alum.Nro_DNI,'   ',alum.nombre,'   ',alum.apellido,'   ',
                    alum.np1:0:2,'   ',alum.np2:0:2,'  = ',
                    ((alum.np1 + alum.np2) / 2):0:2)
     else
        writeln('   No se encuentran datos del Alumno ');
        close(f);
        writeln;
        writeln('    Pulse Una Tecla');
        readkey;
      end
   else
      begin
         writeln('   Error De Archivo O No Existe Pulse Una Tecla');
         readkey;
      end;
   end;
 
 
   procedure menu;
   var
     sal : boolean;
     tecla : char;
     begin
        sal := false;
        repeat
           clrscr;
           writeln('    ***** Menu General *****');
           writeln;
           writeln('   1 = Entrada Alumno');
           writeln('   2 = Ver Aprovados');
           writeln('   3 = Mostrar Un Alumno');
           writeln('   4 = Salir');
           writeln;
           writeln('   >>> Elija Opcion <<<');
         repeat
            tecla := readkey;
         until tecla in['1','2','3','4'];
         clrscr;
     case tecla of
  '1' : entradadatos;
  '2' : ListadoAprobados;
  '3' : busqueda_alumno;
  '4' : sal := true;
     end;
     until sal = true;
   end;
 
 
 
 
   begin
      menu;
   end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
2
Comentar
Imágen de perfil de Facu

Ejercicio de archivos (Tengo final ayuda) - Pascal

Publicado por Facu (2 intervenciones) el 20/12/2015 23:41:24
Muchisimas gracias ramon! Desaprobe ya que tuve el final antes de que me pudieras responder, pero tengo otra oportunidad el 28 de este mes, asi que con este codigo de modelo ya puedo practicar...
Muchas gracias :)!
PD: Voy a comentar aca si aprobe o no, si es que no cierran el post.
Saludos
Facundo
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

Ejercicio de archivos (Tengo final ayuda) - Pascal

Publicado por ramon (2158 intervenciones) el 21/12/2015 11:15:09
Suerte compañero
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