I'm new to programming and i'm way out in left field on this one... I'm trying to write a program that takes takes numerical grade inputs and tells you what the letter grade is. The program must keep running until the user hits 'E' or 'e'.

Here's my problem: with what I have written, the Java isnt finding any errors, how ever when I run the program, it either locks up or prints out all the letter grades regardless of my values. ANY help would be greatly appreciated!

Code listed here:

import java.util.Scanner;
public class Grade {
    public static void main(String[] args) {
	String userInput;
	int grade;
	boolean moreOrder = true;
	
	//Prompts the user to input numeric grade
	System.out.println("Enter your numeric grade (0 to 100) or press 'E' to exit.");
	
	while (moreOrder) {
	    
	}
	// creates the scanner class to take inputs from keyboard
	Scanner keyboard = new Scanner(System.in);
	userInput = keyboard.nextLine();
	grade = userInput.charAt(0);
	char letter;
	
	// Shows the program grabs the appropriate letter grade
	if (grade >=90)
	{
	    letter ='A';
	    System.out.println("Your letter grade is " + letter + ".");
	}
	else if (grade >=80)
	{
	    letter ='B';
	    System.out.println("Your letter grade is " + letter + ".");
	}
	else if (grade >=70);
	{
	    letter ='C';
	    System.out.println("Your letter grade is " + letter + ".");
	}
	
	 if (grade >=60);
	{
	    letter ='D';
	    System.out.println("Your letter grade is " + letter + ".");
	}
	 if (grade <=59);
	{
	    letter ='F';
	    System.out.println("Your letter grade is " + letter + ".");
	}
	
	 if (grade == 'E' || grade == 'e')
	{
	    System.out.println("The program has ended. See you next time.");
	    moreOrder = false;
	}
	else
	    System.out.println("Invalid choice, try again.");
	
	    
	}
    }
jasimp commented: Code tags on first post, thank you. +12

For B you have to put greater than 80 and less than 90.
Fix that for the other grades too.
The way you have it now, entering 90 will output all grades higher than F.
That should work.

you have an infinite loop :

while (moreOrder) {
 
	}

I placed the loop in there to keep the program "asking for inputs" until a condition was met (i.e. User inputs 'E' or 'e'). But obviously i might have missed something

char end = 'n';
do
{
   //do logic
}while(end != 'E' || end != 'e');

I placed the loop in there to keep the program "asking for inputs" until a condition was met (i.e. User inputs 'E' or 'e'). But obviously i might have missed something

Yes, but a while loop runs until the condition is no longer true. For example:

int i = 0;

while(i < 10){
System.out.println(i);
i++; // same as i = i + 1;
}

^ The above will print out 0 through 9.
The below code will just continuously print 0.

int i = 0;

while(i < 10){ //I is always less than ten! Just like in your code above where 'moreOrder' is always true! So what's inbetween the brackets just keeps happening.
System.out.println(i);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.