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 6 of 6

Thread: Convert Scores into letter Grades

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Convert Scores into letter Grades

    Hey guys,

    So Im stuck at this situation that my professor gave me. I have no clue about anything about java and I desperately need some help.

    Operation
    Write a separate class called Grade with the letter grade operation, and then write a driver code called GradeApp to test.
    The user enters a numxherical grade from 0 to 100.
    The application displays the corresponding letter grade.
    The driver prompts the user to continue.
    Specifications
    The grading criteria is as follows:
    A 88-100
B 80-87
C 67-79
D 60-66
F <60
    Assume that the user will enter valid integers for the grades.
    The application in the driver code should continue only if the user enters “y” or “Y” to continue.
    Use of meaningful names and comments.
    Your name (last name, first name), class title and section #, the assignment #, and a brief description of the lab must show up at the top of the source code.
    There will be no point if your program does not run. There will be points off if you don’t separate the logic and operation of the grade assignments from the driver code for testing.


  2. #2
    Junior Member
    Join Date
    Sep 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Convert Scores into letter Grades

    do you have any code that you have started on for this assignment

  3. #3
    Member
    Join Date
    May 2013
    Posts
    106
    My Mood
    Amused
    Thanks
    16
    Thanked 9 Times in 9 Posts

    Default Re: Convert Scores into letter Grades

    It's weird how often I see this assignment come up.

    What do you have so far? This looks like a pretty straightforward assignment designed to teach you about compound if statements and basic console input. Do you understand how to take in user input? Do you know how to do if statements?

  4. The Following User Says Thank You to mstabosz For This Useful Post:

    jps (September 11th, 2013)

  5. #4
    Junior Member
    Join Date
    Sep 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Convert Scores into letter Grades

    import java.util.*;
    import java.util.Scanner;

    public class Grades /* This program breaks numerical grades into letter grades, computes the number of students,
    the number of students per letter grade, the range of scores for each letter grade, the
    average score per grade and the class average. */
    {
    public static void main(String[] Args)
    {
    System.out.println("Enter exam scores, followed by -1 when you are done entering scores.");
    Scanner keyboard = new Scanner(System.in);
    int []allGrades = keyboard.nextLine( );
    System.out.println ("You entered the grades for " + allGrades.length + " students.")
    int [] allGrades = new int;
    boolean numbersLeft = true
    while (numbersLeft)
    {
    next = keyboard.nextInt( );
    if (next = < 0)
    numbersLeft = false;
    for int i = 0; i < allGrades.length; i++; {
    if (allGrades[i] >= 90)
    letterGrade = 'A';
    else if (allGrades[i] >= 80)
    letterGrade = 'B';
    else if (allGrades[i] >= 70)
    letterGrade = 'C';
    else if (allGrades[i] >= 60)
    letterGrade = 'D';
    else letterGrade = 'F';
    }
    }

    this is something my friend helped me start on.

    --- Update ---

    import java.util.*;
    import java.util.Scanner;

    public class Grades /* This program breaks numerical grades into letter grades, computes the number of students,
    the number of students per letter grade, the range of scores for each letter grade, the
    average score per grade and the class average. */
    {
    public static void main(String[] Args)
    {
    System.out.println("Enter exam scores, followed by -1 when you are done entering scores.");
    Scanner keyboard = new Scanner(System.in);
    int []allGrades = keyboard.nextLine( );
    System.out.println ("You entered the grades for " + allGrades.length + " students.")
    int [] allGrades = new int;
    boolean numbersLeft = true
    while (numbersLeft)
    {
    next = keyboard.nextInt( );
    if (next = < 0)
    numbersLeft = false;
    for int i = 0; i < allGrades.length; i++; {
    if (allGrades[i] >= 90)
    letterGrade = 'A';
    else if (allGrades[i] >= 80)
    letterGrade = 'B';
    else if (allGrades[i] >= 70)
    letterGrade = 'C';
    else if (allGrades[i] >= 60)
    letterGrade = 'D';
    else letterGrade = 'F';
    }
    }

    this is something my friend helped me start on.

  6. #5
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Convert Scores into letter Grades

    Please use code tags when posting code, instructions can be found on the Announcements page
    Do you have a question about your friend's code?
    Do you have a question about your assignment?
    "Im stuck at this situation that my professor gave me. I have no clue about anything about java and I desperately need some help." ...contains no questions.
    See How to help yourself get help if you are stuck, or ask some questions, explain what it is you need help with. Right now your statement leaves it up to someone to just read the instructions and do the assignment for you.

  7. #6
    Member
    Join Date
    May 2013
    Posts
    106
    My Mood
    Amused
    Thanks
    16
    Thanked 9 Times in 9 Posts

    Default Re: Convert Scores into letter Grades

    Noixam:

    Like JPS said, use the code tags on this forum's software to make your code easier to read. The tags are (code)(/code) but with square brackets instead of parentheses. This is particularly important when you have a nest if-else like that, which is pretty hard to follow without indentation.

    One thing that helps me a lot when working on code is to use some easy to use sample data and run that through the program in my head or on paper (if the program is too complex to keep track of mentally). Try running some sample numbers like 95, 85, 75, 65, and 15 through your program. That way, I can use my human reasoning, which is a lot more flexible than what a computer can do although not nearly as powerful, and come up with a result. If that matches what the computer is giving me, but not what I want, then I know the logic is flawed somewhere in the program.

    Now that I think about it, I think you can do this without compound if statements, if you just nest the if-else statements. But that tends to lead to convoluted code. I'm guessing your teacher is introducing it to you this way with the nesting before moving on to do it with compound ifs. But it's really hard to read your code the way it's formatted.

Similar Threads

  1. [SOLVED] Hangman Program Java: Comparing the User's Guess with Another String Letter by Letter
    By theonlydvr in forum What's Wrong With My Code?
    Replies: 4
    Last Post: June 29th, 2013, 05:35 PM
  2. [SOLVED] help with grades
    By SOLAS in forum What's Wrong With My Code?
    Replies: 17
    Last Post: April 23rd, 2013, 03:25 PM
  3. [SOLVED] Get percent of failing grades from an array
    By thom4065 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 23rd, 2013, 04:54 PM
  4. Students/Grades
    By ruffu054 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: September 12th, 2011, 10:42 AM
  5. Grades project/arrays, loops
    By rochla16 in forum Collections and Generics
    Replies: 1
    Last Post: March 29th, 2011, 12:26 AM