19.4 Réalisation d’un programme séquentiel
411
© Dunod – La photocopie non autorisée est un délit.
dérées dans l’ordre où elles se présentent dans leur projection, on peut écrire les
instructions d’assignation. Le programme ci-dessous a été réalisé en Pascal. Il
correspond à une variante de la séquentialisation de la figure 19.8 (le calcul de
TOTAL-RETENUE et TOTAL-COTISATION a été reporté en fin de programme).
Le second type de séquentialisation pourrait conduire à un autre programme qui lit
des données dans une base de données.
program TR_EMPLOYE;
uses EMP_IN, EMP_OUT, EMP_SUB;
const
max_nT = 1000;
{nombre maximum de périodes}
var
T : 1..max_nT;
{période courante}
nT : integer;
{nombre réel de périodes}
ANCIENNETE :
array[1..max_nT] of integer;
NIVEAU :
array[1..max_nT] of integer;
PRIMES :
array[1..max_nT] of integer;
INDEX :
array[1..max_nT] of integer;
NET_IMPOSABLE :
array[1..max_nT] of real;
RET_FISCALE :
array[1..max_nT] of real;
COTIS_SOCIALE :
array[1..max_nT] of real;
BRUT :
array[1..max_nT] of real;
NET_PAYE :
array[1..max_nT] of real;
TOT_RETENUE_E :
real;
TOT_COTIS_E :
real;
begin
lire_Nombre_Periodes(nT,max_nT);
for T := 1 to nT do begin
lire_ANCIEN(T,ANCIENNETE[T]);
lire_NIVEAU(T,NIVEAU[T]);
while not ((NIVEAU[T] >= 2) and (NIVEAU[T] <= 12)) do
lire_NIVEAU(T,NIVEAU[T]);
lire_PRIME(T,PRIME[T]);
lire_INDEX(T,INDEX[T]);
end;
for T := 1 to nT do begin
BRUT[T] := (BR(ANCIENNETE[T],NIVEAU[T]) + PRIME[T])
* INDEX[T];
COTIS_SOCIALE[T] := CS(BRUT[T],NIVEAU[T]);
NET_IMPOSABLE[T] := BRUT[T] - COTIS_SOCIALE[T];
RET_FISCALE[T] := RF(NET_IMPOSABLE[T]);
NET_PAYE[T] := NET_IMPOSABLE[T] - RET_FISCALE[T];
end;
TOT_RETENUE_E := 0;
for T := 1 to nT do
TOT_RETENUE_E := TOT_RETENUE_E + RET_FISCALE[T];
TOT_COTIS_E := 0;
for T := 1 to nT do
TOT_COTIS_E := TOT_COTIS_E + COTIS_SOCIALE[T];
afficher_NET_PAYE(T,NET_PAYE);
afficher_TOT_RETENUE(TOT_RETENUE);
afficher_TOT_COTIS(TOT_COTISATION)
end.
411
© Dunod – La photocopie non autorisée est un délit.
dérées dans l’ordre où elles se présentent dans leur projection, on peut écrire les
instructions d’assignation. Le programme ci-dessous a été réalisé en Pascal. Il
correspond à une variante de la séquentialisation de la figure 19.8 (le calcul de
TOTAL-RETENUE et TOTAL-COTISATION a été reporté en fin de programme).
Le second type de séquentialisation pourrait conduire à un autre programme qui lit
des données dans une base de données.
program TR_EMPLOYE;
uses EMP_IN, EMP_OUT, EMP_SUB;
const
max_nT = 1000;
{nombre maximum de périodes}
var
T : 1..max_nT;
{période courante}
nT : integer;
{nombre réel de périodes}
ANCIENNETE :
array[1..max_nT] of integer;
NIVEAU :
array[1..max_nT] of integer;
PRIMES :
array[1..max_nT] of integer;
INDEX :
array[1..max_nT] of integer;
NET_IMPOSABLE :
array[1..max_nT] of real;
RET_FISCALE :
array[1..max_nT] of real;
COTIS_SOCIALE :
array[1..max_nT] of real;
BRUT :
array[1..max_nT] of real;
NET_PAYE :
array[1..max_nT] of real;
TOT_RETENUE_E :
real;
TOT_COTIS_E :
real;
begin
lire_Nombre_Periodes(nT,max_nT);
for T := 1 to nT do begin
lire_ANCIEN(T,ANCIENNETE[T]);
lire_NIVEAU(T,NIVEAU[T]);
while not ((NIVEAU[T] >= 2) and (NIVEAU[T] <= 12)) do
lire_NIVEAU(T,NIVEAU[T]);
lire_PRIME(T,PRIME[T]);
lire_INDEX(T,INDEX[T]);
end;
for T := 1 to nT do begin
BRUT[T] := (BR(ANCIENNETE[T],NIVEAU[T]) + PRIME[T])
* INDEX[T];
COTIS_SOCIALE[T] := CS(BRUT[T],NIVEAU[T]);
NET_IMPOSABLE[T] := BRUT[T] - COTIS_SOCIALE[T];
RET_FISCALE[T] := RF(NET_IMPOSABLE[T]);
NET_PAYE[T] := NET_IMPOSABLE[T] - RET_FISCALE[T];
end;
TOT_RETENUE_E := 0;
for T := 1 to nT do
TOT_RETENUE_E := TOT_RETENUE_E + RET_FISCALE[T];
TOT_COTIS_E := 0;
for T := 1 to nT do
TOT_COTIS_E := TOT_COTIS_E + COTIS_SOCIALE[T];
afficher_NET_PAYE(T,NET_PAYE);
afficher_TOT_RETENUE(TOT_RETENUE);
afficher_TOT_COTIS(TOT_COTISATION)
end.
