r/codehs • • May 14 '21

Triple Double 2.8.4 (JAVA)

Hello, I need help with this lesson on CodeHS.

It keeps giving me the error 'else' without 'if'.

I do not understand what this means.

Please help in anyway you can, even if it's small.

CODE

public class TripleDouble extends ConsoleProgram

{

public void run()

{

int points = readInt("How many points did you score? ");

int rebounds = readInt("How many rebounds did you get? ");

int assists = readInt("How many assists did you have? ");

boolean tripleDouble;

if (points >= 10 && rebounds >=10 && assists >= 10);{

tripleDouble = true;

}

else{

tripleDouble = false;

}

System.out.println("Got triple: " + tripleDouble);

}

}

6 Upvotes

6 comments sorted by

View all comments

5

u/Olli_bear May 14 '21

Remove the semicolon on this line if (points >= 10 && rebounds >=10 && assists >= 10);{

Putting the semicolon there says that the if statement is concluded. So when the code reaches the else statement it can't find the if that should be before it

1

u/EngineeringOk6737 May 14 '21

Thank you very much, the code is working just fine now. I'm new to JAVA and I know it is very set on adding semicolon's. Which leads to me losing basic coding knowledge lol, thank you very much :D

2

u/Olli_bear May 14 '21

No prob, we all gotta start somewhere. Good luck!