Jump to content

Need Help With Very Simple Java Problem


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)


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)



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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...