Error message: Error message: the Exception in the thread "is the main" Java. Lang. Error: cannot resolve compilation problems:
D cannot be resolved to a variable
The at AdditionExercise. Main (AdditionExercise. Java: 19)
Code:
import java.util.Scanner;
import java.util.Random;
Public class AdditionExercise {
Public static void main (String [] args) {
The Random rand=new Random ();
Int a=rand. NextInt (100) + 1;
Int b=rand. NextInt (100) + 1;
Scanner sc=new Scanner(System.in);
Do {
System. The out. Println (" please enter the answer ");
System. The out. Println (a + "+ + +"="b");
Int c=sc. NextInt ();
Boolean d=(c==a + b);
If (d)
System. The out. Println (" the answer right ");
if (! D)
System. The out. Println (" wrong answer ");
sc.close();
} while (d);
}
}
CodePudding user response:
import java.util.Random;import java.util.Scanner;
Public class DoTest {
Public static void main (String [] args) {
The Random rand=new Random ();
Int a=rand. NextInt (100) + 1;
Int b=rand. NextInt (100) + 1;
Scanner sc=new Scanner(System.in);
Boolean d=true;//the line
Do {
System. The out. Println (" please enter the answer ");
System. The out. Println (a + "+ + +"="b");
Int c=sc. NextInt ();
D=(c==a + b);
If (d)
System. The out. Println (" the answer right ");
if (! D)
System. The out. Println (" wrong answer ");
//sc. The close (); Such comments
} while (d);
}
}
CodePudding user response:
The