Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1431 connectés 

  FORUM HardWare.fr
  Programmation
  Delphi/Pascal

  [Pascal] probleme

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[Pascal] probleme

n°1948896
kronikshot​ta
Posté le 10-12-2009 à 05:13:34  profilanswer
 

voila plusieurs temps que j'essai de trouver les erreurs de compilation...
 
uses crt;
const
        frais = 10;
        fcinquante = 400;
var
        nopo           : string;
        age            : string;
        sexe           : string;
        montant        : string;
        codeConducteur : string;
        primeb         : string;
        rabais         : string;
        totaux         : string;
        primeNette     : string;
        fichier        : text;
        fich2          : text;
 
 
begin
  clrscr;
 
 
  assign (fichier, 'polices.dat');
  reset (fichier);
 
 
  assign (fich2, 'resultats.txt');
  rewrite (fich2);
 
  totalp := 0.00;
 
  totalf := 0.00;
 
  totalr := 0.00;
 
  totalpn := 0.00;
 
 
  while not (eof(fichier)) do
  begin
     readln (fichier,nopo,age,sexe,montant,codeConducteur);
 
 
     if nopo < 1 000 then nopo := nopo * 1 000;
 
 
     if (nopo % 2 = 0) and (age >= 18) and (age <= 39) and (montant <= 10 000) then
       begin
         primeb := (10 * montant) / 1 000;
       end
     else if (nopo % 2 = 0) and (age >= 18) and (age <= 39) and (montant > 10 000) and (montant <= 50 000) then
            begin
              primeb := (7.55 * montant / 1 000;
            end
          else if (nopo % 2 = 0) and (age >= 18) and (age <= 39) and (montant > 50 000) then
                 begin
                   primeb := fcinquante + (montant * 3 - 150 000) / 1 000;
                 end
               else if (nopo % 2 = 0) and (age >= 40) and (age <= 54) and (montant <= 30 000) then
                      begin
                        primeb := (11 * montant) / 1 000;
                      end
                    else if (nopo % 2 = 0) and (age >= 40) and (age <= 54) and (montant > 30 000) then
                           begin
                             primeb := (8 * montant) / 1 000;
                           end
                         else if (nopo % 2 = 0) and (age >= 55) and (age <= 74) then
                                begin
                                  primeb := (11 * montant) / 1 000;
                                end;
 
 
     if (nopo % 2 = 0) and (age < 55) and sexe = F then
       begin
         rabais := (0.15 * primeb);
       end;
 
 
 
     if (nopo % 2 <> 0) and (age >= 18) and (age <= 25) and sexe = M then
       begin
         primeb := (100 * montant) / 1 000;
       end;
     else if (nopo % 2 <> 0) and (age >= 18) and (age <= 25) and sexe = F then
            begin
              primeb := (55 * montant) / 1 000;
            end;
          else if (nopo % 2 <> 0) and (age >= 26) and (age <= 65) and sexe = F or M then
                 begin
                   primeb := (40 * montant) / 1 000;
                 end;
               else if (nopo % 2 <> 0) and (age >= 66) and (age <= 74) and sexe = M then
                      begin
                        primeb := (45 * montant) / 1 000;
                      end;
                    else if (nopo % 2 <> 0) and (age >= 66) and (age <= 74) and sexe = F then
                           begin
                             primeb := (90 * montant) / 1 000;
                           end;
 
 
     if (nopo % 2 <> 0) and codeConducteur = 1 then rabais := (0.05 * primeb)
     else
       if (nopo % 2 <>0) and codeConducteur = 2 then rabais := 0
       else
         if (nopo % 2 <> 0) and codeConducteur = 3 then rabais := (0.20 * primeb)
         else rabais := 0;
 
 
     if (nopo % 2 <> 0) and codeConducteur = 3 then
       primeNette := primeb + frais - rabais
     else
       primeNette := primeb + frais - rabais;
 
 
     totalp := totalp + primeb;
 
     totalf := totalf + frais;
 
     totalr := totalr + rabais;
 
     totalpn := totalpn + primeNette;
 
 
     writeln('NO-POLICE   = ' ,nopo);
     writeln('AGE         = ' ,age);
     writeln('SEXE        = ' ,sexe);
     writeln('MONTANT     = ' ,montant);
     writeln('FRAIS       = ' ,frais);
     writeln('RABAIS      = ' ,rabais);
     writeln('PRIME-NETTE = ' ,primeNette);
     writeln('-------------------------------------');
     writeln('TOTAUX : ');
     writeln('            = ' ,totalp);
     writeln('            = ' ,totalf);
     writeln('            = ' ,totalr);
     writeln('            = ' ,totalpn);
     writeln('--------------------------------------');
 
  end;
 
  close (fichier);
  close (fich2);
 
 
end.
 
 
 
 
merci =)

mood
Publicité
Posté le 10-12-2009 à 05:13:34  profilanswer
 

n°1948897
Profil sup​primé
Posté le 10-12-2009 à 05:35:46  answer
 

Citation :

totalp := 0.00;
 
  totalf := 0.00;
 
  totalr := 0.00;
 
  totalpn := 0.00;
 


 
Ce sont des variables, des constantes ?
Déclarée où ?
 
Après tu as plein de comparaison entre string et entier, ça peut pas marcher à mon avis.
 
Voila, j'ai pas de compilo pascal sur moi.

n°1948899
kronikshot​ta
Posté le 10-12-2009 à 05:51:38  profilanswer
 

pour les := 0 .00 ce sont des accumulateur . et pour les comparaisons entre string et entier je vois pas vraiment..  
 
----pour le reste
je li a partir d'un fichier, je traite les donnees et ensuite j'enregistre les resultats dans un fichier .txt
 
j'utilise juste des string excepté 2 fois pour les variables
 
 
 
merci

n°1948903
Profil sup​primé
Posté le 10-12-2009 à 06:11:59  answer
 

j'ai commencé à corriger, suit l'exemple et reviends dans une heure avec les corrections.
 

Code :
  1. procedure toto;
  2.  
  3.  
  4. const
  5.        frais = 10;
  6.        fcinquante = 400;
  7. var
  8.        nopo           : string;
  9.        age            : string;
  10.        sexe           : string;
  11.        montant        : string;
  12.        codeConducteur : string;
  13.        primeb         : string;
  14.        rabais         : string;
  15.        totaux         : string;
  16.        primeNette     : string;
  17.        fichier        : text;
  18.        fich2          : text;
  19.  
  20.        totalp : real ;
  21.  totalf : real;
  22.  
  23.  totalr: real;
  24.  
  25.  totalpn :real;
  26. begin
  27.  
  28.  
  29.  
  30.  assign (fichier, 'polices.dat');
  31.  reset (fichier);
  32.  
  33.  
  34.  assign (fich2, 'resultats.txt');
  35.  rewrite (fich2);
  36.  
  37.  totalp := 0.00;
  38.  
  39.  totalf := 0.00;
  40.  
  41.  totalr := 0.00;
  42.  
  43.  totalpn := 0.00;
  44.  
  45.  
  46.  while not (eof(fichier)) do
  47.  begin
  48.     readln (fichier,nopo,age,sexe,montant,codeConducteur);
  49.  
  50.  
  51.     if (nopo < 1000) then nopo := nopo * 1000;

n°1948904
kronikshot​ta
Posté le 10-12-2009 à 06:34:49  profilanswer
 

jai definis mes accumulateurs comme des variable réel
et mon nombre d'erreurs est descendu a 3  YEAHHHH
 
lol
 
etais-ce le seul changement que j'avais a apporter?
 
merci encore pour ton aide

n°1948905
Profil sup​primé
Posté le 10-12-2009 à 06:45:17  answer
 

kronikshotta a écrit :

jai definis mes accumulateurs comme des variable réel
et mon nombre d'erreurs est descendu a 3  YEAHHHH
 
lol
 
etais-ce le seul changement que j'avais a apporter?
 
merci encore pour ton aide


On peut savoir, de quelle erreur il s'agit, parce que moi j'en vois plus de trois... A moins que tu compte pas le nombre d'occurrence de chacune.
Peux tu comparer un (10) avec un "toto" ?
 

n°1948907
kronikshot​ta
Posté le 10-12-2009 à 06:48:47  profilanswer
 

je n'ai aucun talent en programmation .. lol
 
entk je te laisse aller
 
et milles merci pour ton aide
 et pour les 3 erreurs c le programme mais je suis de ton avi que je dois avoir bcp plus d'erreur de structure etc.  
 
merciiiiiiiiiiiiiiii

n°1948908
kronikshot​ta
Posté le 10-12-2009 à 06:53:08  profilanswer
 

ah oui j'oubliais ne te gene pas si tu desire ajouter des procedures et des fonctions =)  
 
 
Merciiii

n°1948922
kronikshot​ta
Posté le 10-12-2009 à 09:18:02  profilanswer
 

puise-je avoir des nouvelles SVP
 
 
XD  
 
 
Merci :p

n°1948935
Profil sup​primé
Posté le 10-12-2009 à 10:12:51  answer
 

kronikshotta a écrit :

puise-je avoir des nouvelles SVP
 
 
XD  
 
 
Merci :p


 
enregistres-toi sur une news list pas sur un forum.


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Delphi/Pascal

  [Pascal] probleme

 

Sujets relatifs
Probleme Look And Feel et Export.[ Resolu ] Probleme avec mon script menu
probleme requete imbriquéeProblème de génération de fichier excel sous easyPHP 1.8
[Pascal / SDL] Problème pour gérer les Threads(PASCAL) Rotation d'un volume, big probleme!!!
Turbo pascal: problème pour résoudre un exercice[Delphi] Probleme de pascal
[Pascal] problème de nombres ... ???[Pascal] -> Probleme de buffer ...
Plus de sujets relatifs à : [Pascal] probleme


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR