Je suis dégouté de ce programme

Résolu
Signaler
Messages postés
46
Date d'inscription
mercredi 26 mars 2008
Statut
Membre
Dernière intervention
28 mai 2008
-
Messages postés
987
Date d'inscription
mardi 31 mai 2005
Statut
Membre
Dernière intervention
30 août 2012
-
Bonjour!!!
ce programme ci dessoum'a souffer beaucoup
j'ai pas compris ou est le probleme
  void Calculer_actionPerformed(ActionEvent e) {
    int i;
    if (i1.isSelected())
   {
     double A = Double.parseDouble(A.gettext());
     int N = Integer.parseInt(N.getText());
     double Temp = 1.0;
     double Result = 1.0;
     double P;
     for (i = 1; i <= N; i++)
     {
       Temp = Temp * (i / A);
       Result = Result + Temp;
     }
     P = (i/Result) * 100.0;
     P.setText(" " + P);
   }
   else
       if (i2.isSelected())
       {
        double A = 0;
        int N = N.gettext();
        double P = Double.parseDouble(P.gettext());
        double Temp = 1;
        double Result = 1;
     do {
       A = A + 0.001;
       for ( i = N; i > 0; i--) {
         Temp = Temp * (i / A);
         Result = Result + Temp;
       }
       Result = (i / Result) * 100;
     }
     while (Result != P);
     A.setText(" " + A);
   }
   else
   if (i3.isSelected()) {
     double A = A.gettext();
     int N = 0;
     double P = P.gettext();
     double Temp = 1;
     double Result = 1;
     do {
       N++;
       for (i = N; i > 0; i--) {
         Temp = Temp * (i / A);
         Result = Result + Temp;
       }
       Result = (i / Result) * 100;
     }
     while (Result != P);
     N.setText(" " + N);
   }
   else
     jLabel5.setText("Un seul champ doit être indéfinie");


  }

les erreurs sont:



<li>double cannot be dereferenced at line 131 (131:38)
</li>
<li>int cannot be dereferenced at line 132 (132:33)
</li>
<li>double cannot be dereferenced at line 142 (142:8)
</li>
<li>int cannot be dereferenced at line 148 (148:19)
</li>
<li>double cannot be dereferenced at line 149 (149:41)
</li>
<li>double cannot be dereferenced at line 161 (161:8)
</li>
<li>double cannot be dereferenced at line 165 (165:19)
</li>
<li>double cannot be dereferenced at line 167 (167:19)
</li>
<li>int cannot be dereferenced at line 179 (179:8)
</li>
<li>variable A might not have been initialized at line 131 (131:36)
</li>
<li>variable N might not have been initialized at line 132 (132:31)
</li>
<li>variable N might not have been initialized at line 148 (148:17)
</li>
<li>variable P might not have been initialized at line 149 (149:39)
</li>
<li>variable A might not have been initialized at line 165 (165:17)
</li>
<li>variable P might not have been initialized at line 167 (167:17) </li>

1 réponse

Messages postés
987
Date d'inscription
mardi 31 mai 2005
Statut
Membre
Dernière intervention
30 août 2012
25
Bonjour
double A = Double.parseDouble(A.gettext());
int N = Integer.parseInt(N.getText());
Il y a peut etre des conflits : entre test variable, (tes variables locales double A et int N et tes variables A et N qui sont a priori des label.
essaye de trouver d'autre noms pour les variables locales.

Cdt