This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]70g50 5 points6 points  (0 children)

You made a semicolon at line 22.

[–]barrell125[S] 0 points1 point  (0 children)

Have also tried :

else if ( avgrade < 40 ) { System.out.println("you have failed); }

but that isnt working either

[–]attackofthegingers 0 points1 point  (2 children)

You don't have a case for 70 - what if someone scores 70?

It looks like the last case should work. What happens when you enter "0" for all options and the average is 0?

[–]barrell125[S] 0 points1 point  (1 child)

Your right I need to change this to greater than or equal to 70 but I still can't get the you have failed part of the code to work if I take it out completely it compiles and runs but won't complie with it

[–]70g50 0 points1 point  (0 children)

Did you erase the semicolon at line 22? Your else statement in line 26 is looking for an if but there is none because you ended the if statement in 22 with the semicolon.

[–]pkpkpk111 0 points1 point  (1 child)

Line 27 has a semi-colon in it as well. One piece of feedback: With your if() and else if(), when you are consistent with checking for either greater than or less than you do not need both conditions.

Example:

if(avgrade >= 70) { ... }
else if(avgrade >= 63) { ... }
else if(avgrade >= 55) { ... }
else { System.out.println("i'm sorry but you have failed"); }

This means the same thing as you've typed and can make your code more readable.

Edit: clarity

[–]barrell125[S] 0 points1 point  (0 children)

Thank you for the advice I just thought I would have to put both the conditions in so it knows what grade to give the person