-1
I have the following code:
public class String verifyWord(String wordChosen, Scanner reader){ //linha 1
boolean answeredCorrectly = false;
int tries = 1;
String wordChosen = random.nextInt();
String answer = wordChosen;
while(tries>0 && answeredCorrectly == false) { //linha 6
answer = reader.nextInt();
if(wordChosen == answeredCorrectly) {
System.out.println("You got it right");
answeredCorrectly=true;
}
else if(answered =! wordChosen){
System.out.println("Wrong");
}
}
}
In the first line according to the program there is an error, after String
says I must put a key {
, but I believe that this is not the solution. On line 6 in while
the program says:
"illegal start of type".~
I started quite recently and I don’t understand how to solve these mistakes.
This is the entire code of your class?
– Sorack
no, just a part
– Diana Madeira
Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site.
– Maniero