I’m doing the Cumulative Project 3 ( link ) and here is the part of the code I’m getting errors from:
public String getGameOverMessage(int totalCorrect, int totalQuestions) {
if (totalCorrect == totalQuestions) {
String 1 = "You got total " + totalCorrect + " correct! You won!";
System.out.println(1);
return 1;
} else {
String 2 = "You got " + totalCorrect + " out of " + totalQuestions + ". Better luck next time!";
System.out.println(2);
return 2;
}
the errors I’m getting are the following:
MainActivity.java:11: error: not a statement
String 1 = "You got total " + totalCorrect + " correct! You won!";
^
MainActivity.java:11: error: ';' expected
String 1 = "You got total " + totalCorrect + " correct! You won!";
^
MainActivity.java:11: error: not a statement
String 1 = "You got total " + totalCorrect + " correct! You won!";
^
MainActivity.java:15: error: not a statement
String 2 = "You got " + totalCorrect + " out of " + totalQuestions + ". Better luck next time!";
^
MainActivity.java:15: error: ';' expected
String 2 = "You got " + totalCorrect + " out of " + totalQuestions + ". Better luck next time!";
^
MainActivity.java:15: error: not a statement
String 2 = "You got " + totalCorrect + " out of " + totalQuestions + ". Better luck next time!";
^
6 errors
I’ve googled about String concatenation and am following the hints of the exercise in terms of building the string, so I’m unsure what “not a statement” means here. All the examples about “not a statement” I found were missing + marks only. Also, when it says ; expected, I have ; at the ends. So I’m stumped. There’s something I’m not seeing and I’ve been at it for over an hour.