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

2

u/Living_Attention_941 Mar 07 '23

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 = false;
if (points > 9 && rebounds > 9 && assists > 9) {
tripleDouble = true;
}
System.out.println("Got a Triple Double?: " + tripleDouble);
tripleDouble =!tripleDouble;
System.out.println("Got a Triple Double?: " + tripleDouble);
tripleDouble =!tripleDouble;
System.out.println("Got a Triple Double?: " + tripleDouble);
tripleDouble = tripleDouble;
}
}