Jump to content

Need Help With Very Simple Java Problem


jamesy

Recommended Posts

hi guys thanks for the time im getting this error "  error: illegal start of expression

else if (grades >=40 && <=54) " i bascially want it to out put " d" if the grade is between 40 and 54 thanks again 
 
here is my code 
 
import java.util.Scanner;
public class grade {
public static void main(String[] args) {
 
Scanner myScanner = new Scanner(System.in);
int grades;
System.out.print("Please Enter Your Grade Percentage --  ");
grades = myScanner.nextInt();
 
if(grades <40)
 
System.out.print("Congradulations You Are Awarded An  F  Mark ");
 
 
else if (grades >=40 && <=54)
 
System.out.println("d");
 
}
}
 
 
 
 

 

Share this post


Link to post
Share on other sites

What? You mean to say if you get between 54 and 40 you get a "d" and an "f" isn't until you get below a 40! Man teachers are getting soft.

 

First things first though. It would help if you wrapped your code in the code tag. It just makes it easier to read.

 

Now to your code. In your else if statement you left off the "grades", try this:

else if (grades >= 40 && grades <= 54)

 

edit:

I need to work on punctuation.

Edited by flareback
  • Like 1

Share this post


Link to post
Share on other sites

Flare back thanks a mill it worked perfectly !! yeah well its a math project i just started java two weeks ago so im a proper newbie ha yeah thats the marking scheme on the brief bit theirs more to be added , your a led thanks for the advice on adding the code and for your help dude

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...