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 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
| program record2;
uses
crt;
type
laliste = record
active : Boolean;
numero : integer;
prenom : string;
nom : string;
age: integer;
salaire:real;
end;
liste2=file of laliste;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure menu(var choix:integer);
Begin
clrscr();
writeln('*********************************************************');
writeln('*********************************************************');
writeln('*** ***');
writeln('*** 1- Ajouter une fiche active. ***');
writeln('*** 2- Liste complete des fiches actives. ***');
writeln('*** 3- Liste complete des fiches non actives. ***');
writeln('*** 4- Statistiques age des employer(fiche active) ***');
writeln('*** 5- Total de tous les salaires(fiche active) ***');
writeln('*** 6- Desastiver une fiche par le numero d''employer ***');
writeln('*** 7- Quitter ***');
writeln('*** ***');
writeln('*********************************************************');
writeln('*********************************************************');
write('Quel option choississer vous? : ');
readln(choix);
End;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure ajouter(var liste:laliste; var unit1:liste2);
Var
prenomreal,nomreal:integer;
max:integer;
min:integer;
Begin
max:=25;
min:=0;
clrscr();
reset(unit1);
while not eof(unit1) do
read(unit1, liste);
write(liste.nom);
liste.active:= True;
write('Entrer le numero : ');
readln(liste.numero);
repeat
write('Entrer le prenom : ');
readln(liste.prenom);
prenomreal:=length(liste.prenom);
until ((prenomreal<=max) and (prenomreal>min));
repeat
write('Entrer le nom : ');
readln(liste.nom);
nomreal:=length(liste.prenom);
until ((nomreal<=max) and (nomreal>min));
write('Entrer l''age : ');
readln(liste.age);
write('Entrer le salaire : ');
readln(liste.salaire);
write(unit1,liste);
End;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure affichertrue(var unit1:liste2; liste:laliste);
Var
i:integer;
Begin
clrscr();
write('Affichage des classes actives : ');
reset(unit1);
writeln;
writeln;
i:= 0;
while not eof(unit1) do begin
i := i + 1;
read(unit1, liste);
if liste.active=True then
writeln(i, ' : ', liste.numero, ' ', liste.prenom,' ',liste.nom,' ',liste.age,' ',liste.salaire:0:2,'$');
end;
readln;
End;
procedure afficherfalse(var unit1:liste2; liste:laliste);
Var
i:integer;
Begin
clrscr();
write('Affichage des classes non-actives : ');
reset(unit1);
writeln;
writeln;
i:= 0;
while not eof(unit1) do begin
i := i + 1;
read(unit1, liste);
if liste.active=false then
writeln(i, ' : ', liste.numero, ' ', liste.prenom,' ',liste.nom,' ',liste.age,' ',liste.salaire:0:2,'$');
end;
readln;
End;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure stats(var unit1:liste2; liste:laliste);
var
min,max,chiffre,i:integer;
moy:real;
Begin
min:=32000;
max:=0;
moy:=0;
i:=0;
clrscr();
reset(unit1);
while not eof(unit1) do begin
read(unit1, liste);
if (liste.active=true) then begin
chiffre:=liste.age;
moy:=(chiffre+moy);
i:=i+1;
if (chiffre>max) then
max:=chiffre;
if (chiffre<min) then
min:=chiffre;
end;
end;
moy:=moy/i;
writeln('Statistiques :');
writeln;
writeln('La moyenne : ',moy:0:2);
writeln('Le minimum : ',min);
writeln('Le maximum : ',max);
readln;
End;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure totalmoney(var unit1:liste2; liste:laliste);
var
chiffre,total:real;
Begin
total:=0;
clrscr();
reset(unit1);
while not eof(unit1) do begin
read(unit1, liste);
if (liste.active=true) then begin
chiffre:=liste.salaire;
total:=chiffre+total;
end;
end;
writeln('Statistique de tous les salaires :');
writeln;
writeln('Tous les salaires : ',total:0:2);
readln;
End;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure desactiver(var unit1:liste2; liste:laliste);
Var
i,j,numemployer:integer;
Begin
i:=0;
clrscr();
writeln('Quel est le numero d''employer qui va etre desastive? : ');
readln(numemployer);
reset(unit1);
repeat
read(unit1, liste);
i:=i+1;
until (numemployer=liste.numero);
for j:=0 to (i) do
read(unit1, liste);
liste.active:= False;
write(unit1,liste);
End;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
VAR
unit1 : liste2;
liste : laliste;
choix : integer;
BEGIN
with liste do
begin
numero :=0;
nom := 'a';
prenom := 'b';
age:= 0;
salaire:=0;
end;
//Je pense faire une procédure ici pour le try et le exept mais je ne sait pas comment utiliser le try et except.
assign (unit1,'info1.dat');
repeat
menu(choix);
if choix = 1 then
ajouter(liste,unit1);
if choix = 2 then
affichertrue(unit1,liste);
if choix = 3 then
afficherfalse(unit1,liste);
if choix = 4 then
stats(unit1,liste);
if choix = 5 then
totalmoney(unit1,liste);
if choix = 6 then
desactiver(unit1,liste);
until (choix=7);
close(unit1);
END. |
Partager