Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 10 of 10

Thread: Grading Program

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Grading Program

    Hey all, I'm a beginner programmer and I've been working to find the solution to my issue for a few hours now. What I am trying to do is have the user prompted for his/her name and 5 grades after that. The 5 grades will combine to make a letter grade using the "+" and "-" system. I have the first part done but I am really struggling trying to figure out how to get the appropriate letter grade to coincide with the number grade. This is what I have so far. Any help would be greatly appreciated!!
    import java.util.Scanner;
     
    public class Lab1 {
    public static void main (String args []){
    	Scanner input = new Scanner(System.in);
    	System.out.println("Enter Student's Name ");
    	String studentName = input.nextLine();
    	System.out.println("Please Enter your Lab Grade, Participation Grade, Test 1 Grade, Test 2 Grade, and Final Exam Grade");
    	int Labs = input.nextInt();
    	if (Labs > 56)
    		System.out.println("Error: Your Labs Grade " + Labs + " is too high!");
    	int Participation = input.nextInt();
    	if (Participation > 4)
    		System.out.println("Error: Your Participation Grade " + Participation + " is too high!");
    	int Test1 = input.nextInt();
    	if (Test1 > 12)
    		System.out.println("Error: Your Test 1 Grade " + Test1 + " is too high!");
    	int Test2 = input.nextInt();
    	if (Test2 > 12)
    		System.out.println("Error: Your Test 2 Grade " + Test2 + " is too high!");
    	int FinalExam = input.nextInt();
    	if (FinalExam > 16)
    		System.out.println("Error: Your Final Exam Grade " + FinalExam + " is too high!");
    	int  FinalGrade = (Labs + Participation + Test1 + Test2 + FinalExam);
    	if (FinalGrade > 100)
    		System.out.println("Error: Your Final Grade " + FinalGrade + " is too high!");
    	char LetterGrade;
    	if (FinalGrade >= 97)
    		LetterGrade = 'A'
    	System.out.println("The final grade for " + studentName + "is an " + LetterGrade + "+");
    	else if (FinalGrade >= 93)
    		LetterGrade = 'A'
    	System.out.println("The final grade for " + studentName + "is an " + LetterGrade);
    	if (FinalGrade >= 90)
    		LetterGrade = 'A';
    	System.out.println("The final grade for " + studentName + "is an " + LetterGrade + "-");
    	if (FinalGrade >= 87)
    		LetterGrade = 'B';
    	System.out.println("The final grade for " + studentName + "is a " + LetterGrade + "+");
    	if (FinalGrade >= 83)
    		LetterGrade = 'B';
    	System.out.println("The final grade for " + studentName + "is a " + LetterGrade);
    	if (FinalGrade >= 80)
    		LetterGrade = 'B';
    	System.out.println("The final grade for " + studentName + "is a " + LetterGrade + "-");
    	if (FinalGrade >= 77)
    		LetterGrade = 'C';
    	System.out.println("The final grade for " + studentName + "is a " + LetterGrade + "+");
    	if (FinalGrade >= 73)
    		LetterGrade = 'C';
    	System.out.println("The final grade for " + studentName + "is a " + LetterGrade);
    	if (FinalGrade >= 70)
    		LetterGrade = 'C';
    	System.out.println("The final grade for " + studentName + "is a " + LetterGrade + "-");
    	if (FinalGrade >= 60)
    		LetterGrade = 'D';
    	System.out.println("The final grade for " + studentName + "is a " + LetterGrade);
    	if (FinalGrade <= 59)
    		LetterGrade = 'F';
    	System.out.println("The final grade for " + studentName + "is an " + LetterGrade);
    }
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,631
    Thanks
    45
    Thanked 1,959 Times in 1,933 Posts

    Default Re: Grading Program

    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Sep 2012
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Grading Program

    I'm just trying to get some help Norm

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,631
    Thanks
    45
    Thanked 1,959 Times in 1,933 Posts

    Default Re: Grading Program

    No problem. Just be sure to tell everyone where else the question has been posted so no one wastes time answering a question that has already been answered.
    Also if someone on one forum wants to see the answers that are on another forum, there is a link to where the answers are.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Sep 2012
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Grading Program

    Thanks for your help. Just making sure that people didn't think I was spamming and ignore my question. I've been stuck for hours now with the same issue.

  6. #6
    Junior Member
    Join Date
    Sep 2012
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Grading Program

    Ok, I have figured most of this out, the only issue that I'm having now is that when it assigns a LetterGrade to the FinalGrade, it is listing all the scores below that LetterGrade as well.

    Ex: For a C, it is also saying that they received a C-, D, and F.

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,631
    Thanks
    45
    Thanked 1,959 Times in 1,933 Posts

    Default Re: Grading Program

    Please post the full contents of console from when you execute the program and add some comments describing what is wrong with the output and show what the output should look like.
    If you don't understand my answer, don't ignore it, ask a question.

  8. #8
    Junior Member
    Join Date
    Sep 2012
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Grading Program

    The output is as follows:

    Enter Student's Name
    Greg
    Please Enter your Lab Grade, Participation Grade, Test 1 Grade, Test 2 Grade, and Final Exam Grade
    56 4 12 11 15
    The final grade for Greg is an A+
    The final grade for Greg is an A
    The final grade for Greg is an A
    The final grade for Greg is a B+
    The final grade for Greg is a B
    The final grade for Greg is a B-
    The final grade for Greg is a C+
    The final grade for Greg is a C
    The final grade for Greg is a C-
    The final grade for Greg is a D
    Total: 98

    For a 98 I need it only to say that the final grade is an A+..

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,631
    Thanks
    45
    Thanked 1,959 Times in 1,933 Posts

    Default Re: Grading Program

    Can you post the code the prints out the line that is wrong?

    Check why the code prints " Total: 98" instead of "The final grade for Greg is a A+".

    Why are all of the other print outs in the format of: "The final grade for Greg is a ..."
    If you don't understand my answer, don't ignore it, ask a question.

  10. The Following User Says Thank You to Norm For This Useful Post:

    greg2186 (September 6th, 2012)

  11. #10
    Junior Member
    Join Date
    Sep 2012
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Grading Program

    Thanks Norm I figured it out. I really appreaciate your help

Similar Threads

  1. Student Grading
    By happychild in forum What's Wrong With My Code?
    Replies: 4
    Last Post: September 14th, 2011, 12:09 PM
  2. [SOLVED] Student grading application
    By Melawe in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 18th, 2011, 12:08 AM
  3. grading program help
    By devilhanzou in forum What's Wrong With My Code?
    Replies: 6
    Last Post: February 14th, 2011, 08:01 AM
  4. Grading
    By BuhRock in forum Java Theory & Questions
    Replies: 5
    Last Post: April 18th, 2010, 05:05 PM
  5. [SOLVED] Problem with Grading calculator in java program
    By Peetah05 in forum What's Wrong With My Code?
    Replies: 23
    Last Post: March 28th, 2009, 04:25 PM

Tags for this Thread