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

  FORUM HardWare.fr
  Programmation
  Java

  java

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

java

n°1793056
fayss1190
Posté le 28-09-2008 à 17:30:34  profilanswer
 

Bonjour,  
 
 je susi débutant et e n arrive pas a rectifier mon erreure ...
svp une petite aide ^^
 
 
 
public class Exercice2_11 {
 
   public static java.util.Scanner scanner = new java.util.Scanner(System.in);
 
      public static void main(String[] args) {
 
      int premierNombre, secondNombre, reponseEleve, deuxiemeChance, troisiemeChance, reponseCorrecte;
 
         premierNombre = unEntierAuHasardEntre (0, 10);  
         secondNombre = unEntierAuHasardEntre (0, 10);
 
         System.out.println ("Calculez : " );
 
         System.out.println ( premierNombre * secondNombre + "=" + " ... " );
         reponseEleve = scanner.nextInt();
         
      if (reponseEleve = reponseCorrecte )  
         System.out.println ("Très bien" );
      else {
         System.out.println ("La réponse est fausse!" );
         System.out.println ("Deuxième chance :" );  
      deuxiemeChance = scanner.nextInt();
         if (deuxiemeChance = reponseCorrecte )  
         System.out.println ("Très bien" );
            else{  
            System.out.println ("La réponse est fausse!" );
            System.out.println ("Vous avez le droit à une dernière chance :" );
            troisiemeChance = scanner.nextInt();
            if (troisiemeChance = reponseCorrecte)
            System.out.println ("Très bien" );
               else
                  System.out.println ("La réponse est fausse!" );
                  System.out.println ("La réponse correcte était :" + reponseCorrecte);
               
               
            }
         }
      }
 
   public static int unEntierAuHasardEntre (int valeurMinimale, int valeurMaximale){
      double nombreRéel;
      int résultat;
 
      nombreRéel = Math.random();
      résultat = (int) (nombreRéel * (valeurMaximale - valeurMinimale + 1))
                        + valeurMinimale;
      return résultat;
   }
   }
 
 
 
 
 
 
 
 
Message d erreur :
 
ÏÏ«Ï ----jGRASP exec: javac -g C:\Documents and Settings\Ouariors\Mes documents\Fayçal école\Algorithmique\Fiche 2 26.09.2008\Exercice2_11.java
ÏϧÏ
ϼ§ÏExercice2_11.java:18: incompatible types
ÏϧÏfound   : int
ÏϧÏrequired: boolean
ÏÏ§Ï            if (reponseEleve = reponseCorrecte )  
ÏÏ§Ï                             ^
ϼ§ÏExercice2_11.java:24: incompatible types
ÏϧÏfound   : int
ÏϧÏrequired: boolean
ÏÏ§Ï                    if (deuxiemeChance = reponseCorrecte )  
ÏÏ§Ï                                       ^
ϼ§ÏExercice2_11.java:30: incompatible types
ÏϧÏfound   : int
ÏϧÏrequired: boolean
ÏÏ§Ï                            if (troisiemeChance = reponseCorrecte)
ÏÏ§Ï                                                ^
ϼ§ÏExercice2_11.java:45: possible loss of precision
ÏϧÏfound   : double
ÏϧÏrequired: int
ÏÏ§Ï            nombreRéel = Math.random();
ÏÏ§Ï                                    ^
ÏϧÏ4 errors
ÏϧÏ
ÏÏ§Ï ----jGRASP wedge2: exit code for process is 1.
ÏÏ©Ï ----jGRASP: operation complete.
 
 
Merci


---------------
fayss
mood
Publicité
Posté le 28-09-2008 à 17:30:34  profilanswer
 

n°1793060
masklinn
í dag viðrar vel til loftárása
Posté le 28-09-2008 à 17:39:32  profilanswer
 

java


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
n°1793133
artscoop
la fin des temps
Posté le 28-09-2008 à 22:15:35  profilanswer
 

Salut Fayçal,
On écrit pas if (troisiemeChance = reponseCorrecte)
on écrit plutôt if (troisiemeChance == reponseCorrecte)
 
Quand tu fais un "if" et que tu veux comparer deux valeurs, tu utilises le "=="
 
ex. : if (a==1)
 
Je t'explique :
a==1 renvoie un booléen (qui contient soit vrai soit faux. Si a est égal à 1, le booléen contiendra vrai)
 
Et le "if" demande un booléen entre parenthèses...
 
@+


---------------
Site de rencontre

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Java

  java

 

Sujets relatifs
Connection mysql --> Erreur java.io.EOFExceptionproblrmr de classepath avec java sous linux
Récupérer l'adresse MAC grace à un applet java[JSF] Peut-on executer du code java avant d'appeler la jsp ?
Copie superficielle et copie profonde en JAVAC# comparativement à Java
parser html avec javapb applet et classe java
Appli Java, Compression gzip des jsp 
Plus de sujets relatifs à : java


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)