+ 1
Can someone please tell me how to fix the error in the last line of code? Eclipse said TABLE1 cannot be resolved to a variable
import java.util.Scanner; public class TableDeMultiplication { public static void main(String[] args) { // Tables de Multiplication Scanner clavier = new Scanner(System.in); do { System.out.println("Quelle table de multiplication vous interesse?"); final int TABLE1 = clavier.nextInt(); System.out.println("Quelle est la limite de votre multiplicateur?"); final int MULTIP1 = clavier.nextInt(); if(TABLE1>=0 && MULTIP1>=0) { for( int i=0; i<=MULTIP1; i++) { System.out.println( TABLE1 + " multiplié par " + i + " est égal à : " + (TABLE1*i)); } } else { System.out.println("Vous devez rentrer des nombres positifs!");}; } while(TABLE1<=0 || MULTIP1<=0); } }
7 Answers
+ 5
Here you go ...
//Can someone please tell me how to fix the error in the last line of code? Eclipse said TABLE1 cannot be resolved to a variable
import java.util.Scanner;
public class TableDeMultiplication
{
public static void main(String[] args)
{
// Tables de Multiplication
Scanner clavier = new Scanner(System.in);
int TABLE1, MULTIP1;
do
{
System.out.println("Quelle table de multiplication vous interesse?");
TABLE1 = clavier.nextInt();
System.out.println("Quelle est la limite de votre multiplicateur?");
MULTIP1 = clavier.nextInt();
if(TABLE1>=0 && MULTIP1>=0)
{
for( int i=1; i<=MULTIP1; i++)
{
System.out.println( TABLE1 + " multiplié par " + i + " est égal à : " + (TABLE1*i));
}
}
else
{
System.out.println("Vous devez rentrer des nombres positifs!");
}
} while(TABLE1<=0 || MULTIP1<=0);
}
}
+ 3
Looks like the variable TABLE1in the condition is out of scope. define it at the start, before the "do" block instead...
+ 3
Also, you may not want to define TABLE1 as final as it is supposed to be a variable, not a constant....
+ 3
Same for MULTIPL by the way....
+ 1
thank you very much
+ 1
it works right now
0
i did it but now I have an infinite loop with the "else" statement