Hey guys, im pretty new to java as this is my first time ever taking such a course, and i have an assignment that i have to complete that im stuck on and i have no idea what to do next.

Heres what i have so far, and i doubt its right

import TerminalIO.KeyboardReader;

public class GradingScaleRP1{
   
  private String name;
  private String letter;
  private double grade;
  public int number;
  public int numberR;
  
  public GradingScaleRP1(){
    name = "";
    letter = "";
    grade = 0;
    number = 0;
    numberR = 0;
  }
  
  public GradingScaleRP1(String nm, String range, double average, int n, int nR){
    this();
    name = nm;
    letter = range;
    grade = average;
    number = n;
    numberR = nR;
  }
  
  public static String getLetterGrade(double average){
  String range;
  if (average >= 96)
    range = "A+";
  else if (92 <= average && average <= 95)
    range = "A";
  else if (90 <= average && average <= 91)
    range = "A-";
  else if (86 <= average && average <= 89)
    range = "B+";
  else if (82 <= average && average <= 85)
    range = "B";
  else if (80 <= average && average <= 81)
    range = "B-";
  else if (76 <= average && average <= 79)
    range = "C+";
  else if (72 <= average && average <= 75)
    range = "C";
  else if (70 <= average && average <= 71)
    range = "C-";
  else if (66 <= average && average <= 69)
    range = "D+";
  else if (62 <= average && average <= 65)
    range = "D";
  else if (60 <= average && average <= 61)
    range = "D-";
  else if (average <= 59)
    range = "F";
  return range;
}
  public static double classAverage(){
  }
}

Now, what i have to do is create a method getLetterGrade, which i think i have done correctly, and i also have to have it so it outputs the class average, the class minimum, and the class maximum as letter grades. So im stuck because i have to make it ask the user how many grades there putting in and such to get the average, min, and max, but i first have to figure out how i could get the average which is where im stuck. Hopefully you guys can help., and if you dont understand really what im asking, i can just put the actual question in for you.

Well, i knew the formula, i just dont know a way to go about doing it so it adds the newest grade to the sum of all the others, and then divides it by the number of grades put in

There are a couple of things you can do:

1. Make another class that has an array of these objects, each representing a single student. Then have methods of that new class have the class average, min, and max methods, which basically takes the scores from all the GradingScaleRP1 objects in the array (I would rename this class "Student" so it makes more sense to the reader) and adds them up to get the total score, and then gets the length of the array as the total number of students.

2. Make 4 static variables in this class called classSize, classAverage, classMax, classMin. Have these variables update themselves every time a new object is created and its average is calculated. Because they are static, they will not vary from object to object -- rather, they will be referring to the class as a whole. Then create static accessor methods like getSize(), getClassAverage(), etc, which return these variables.

This article has been dead for over six months. Start a new discussion instead.