To solve just follow these steps:
1) remove the semicolon ( ; ) at the end of line 19
2) Get rid of lines 20, 21,22, and 23. These are all unnecessary. This would make line 19 sit on top of 24 when they are all removed.
Now as far as code goes:
line 21 has an error in that you are trying to set the value to true, but the double equal sign (==) is a comparison operator and not an assignment operator.
On line 23 you can just write the variable if(triangle) instead of if(triangle == true). This is because if() is checking for boolean values true or false. You declare the variable triangle to be a boolean of (disregarding the error) true.
if-else statements only need code blocks if they are to execute more than 1 statement. If you have 1 and only 1 statement, then the block is unnecessary. Now it is not against any rule to add blocks if you don't need them, but keeping your code small (within reason) is desirable. It really would be your preference, but you can write your code like this:
if(/*boolean check*/)System.out.println("Some text");elseSystem.out.println("some other text");
You have a semi-colon (;) after your if statement. You need to remove that. Also, if you declare a variable in a block (like you have declared boolean triangle) you won't be able to access it outside of the block.
Level 18 , Kriva Palanka, Macedonia, The Former Yugoslav Republic of
13 December 2018, 10:56
You cannot start the boolean expression like that. You need to consider the precedence of the parentheses, first you need to check the addition of the two, and then check if the sum is less or more. Hope this helps. Skol!
+1
This website uses cookies to provide you with personalized service. By using this website, you agree to our use of cookies. If you require more details, please read our Terms and Policy.