Variable cannot be resolved
Résolu/Fermé
Absot
by.sonia
- Messages postés
- 778
- Date d'inscription
- mardi 28 octobre 2008
- Statut
- Membre
- Dernière intervention
- 4 septembre 2020
by.sonia
- Messages postés
- 1
- Date d'inscription
- lundi 26 décembre 2011
- Statut
- Membre
- Dernière intervention
- 26 décembre 2011
A voir également:
- Cannot be resolved to a variable
- Java cannot be resolved to a variable - Meilleures réponses
- Cannot be resolved to a variable java - Meilleures réponses
- Variable cannot be resolved ✓ - Forum - Programmation
- (java) x cannot be resolved to a variable ✓ - Forum - Programmation
- [java] nom cannot be resolved to a variable ✓ - Forum - Java
- Cannot be resolved to a variable talend - Forum - Programmation
- Cannot be resolved to a variable java - Forum - Java
8 réponses
hamed01
26 mars 2009 à 20:18
- Messages postés
- 207
- Date d'inscription
- lundi 30 juin 2008
- Statut
- Membre
- Dernière intervention
- 22 juillet 2011
26 mars 2009 à 20:18
ah je vois ....
ta variable choix est declarée dans le do { } while()
place la declaration en dessus, comme suit
------------------------------------------------------------------------------------------
import java.util.Scanner;
public class sdz1 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner lire = new Scanner (System.in);
int choix;
do{
double premier;
double second;
double res;
System.out.println("Saisissez un premier nombre");
premier = lire.nextDouble();
System.out.println("Saisissez un deuxieme nombre");
second = lire.nextDouble();
System.out.print("1 pour ajouter /n" +
"2 pour soustraire /n" +
"3 pour multiplier /n" +
"4 pour diviser /n" +
"5 pour quitter");
choix = lire.nextInt();
switch (choix){
case 1:
res = (premier+second);
System.out.println("Le resultat est " + res);
break;
case 2:
res = (premier-second);
System.out.println("Le resultat est " + res);
break;
case 3:
res = (premier*second);
System.out.println("Le resultat est " + res);
break;
case 4:
res = (premier/second);
System.out.println("Le resultat est " + res);
break;
Default:
System.out.println("Erreur de programmation");
}
}
while ( (choix ==1) || (choix ==2) || (choix ==3) || (choix ==4) );
}
}
ta variable choix est declarée dans le do { } while()
place la declaration en dessus, comme suit
------------------------------------------------------------------------------------------
import java.util.Scanner;
public class sdz1 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner lire = new Scanner (System.in);
int choix;
do{
double premier;
double second;
double res;
System.out.println("Saisissez un premier nombre");
premier = lire.nextDouble();
System.out.println("Saisissez un deuxieme nombre");
second = lire.nextDouble();
System.out.print("1 pour ajouter /n" +
"2 pour soustraire /n" +
"3 pour multiplier /n" +
"4 pour diviser /n" +
"5 pour quitter");
choix = lire.nextInt();
switch (choix){
case 1:
res = (premier+second);
System.out.println("Le resultat est " + res);
break;
case 2:
res = (premier-second);
System.out.println("Le resultat est " + res);
break;
case 3:
res = (premier*second);
System.out.println("Le resultat est " + res);
break;
case 4:
res = (premier/second);
System.out.println("Le resultat est " + res);
break;
Default:
System.out.println("Erreur de programmation");
}
}
while ( (choix ==1) || (choix ==2) || (choix ==3) || (choix ==4) );
}
}