I need help on following homework.
Project Summary: Write a class to manage student grades and an application that uses it to produce a summary report and answer queries about grades.
Part 1
Write a class, called "Grades", to store a set of grades (each grade is a real value from 0 to 100).
The class should define (as part of the API unless stated otherwise):
A (private) array of integers to store the grades it receives.
A constructor that specifies the maximum number of grades it can hold.
A method called "addGrade" that receives a grade and stores it.
A method called "numGrades" that returns the number of grades added so far.
A function called "letterGrade" that takes a numeric grade and returns a character (A,B,C,D or F) representing the corresponding letter grade (on a ten point scale). (e.g. 90-100:A, 80-90:B, etc)
A method called "howMany" that takes a letter grade and returns the number of students that earned that letter grade.
A toString method that returns a string containing all the numeric grades, formatted nicely as you see fit. (you may find this method handy for debugging).
Notes:
None of the methods in your class should do any input from a file or the keyboard, or do any output the the display.
When instantiating an array, its size doesn't have to be a literal or constant; it may be a variable or an expression.
The index used for an array reference may be an expression.
Methods in your class may call other methods in the class.
(e.g. letterGrade may be called whenver you need to convert from a numeric to letter grade.)
You don't need to declare or use more than one array.
Only two of the methods above require a loop; no nested loops are required.
Part 2
Write an application using your class.
Part 2A: Read and output the grades
Your application should read a sequence numeric grades from a file named "quizgrades.txt" and store the grades in an instance of your class (using the addGrade() method). You should read as many grades as the file contains. As your read in each grade, print it along with its corresponding letter grade.
For example, quizgrades.txt might contain:
75 90 83
95
20 48
and your output might look like this:
75 C
90 A
83 B
95 A
20 F
48 F
Only one loop is necessary; don't write more than one for this part.
After reading in and outputting the grades, use the numGrades() method of the instance to output the number of grades entered, and use the toString() method of the instance to output the contents of the instance.
For example:
6 Grades: 75 90 83 95 20 48
Part 2B: Answer queries about grades
Repeatedly prompt the user for a letter grade. For each grade entered, report to the user how many students earned that letter grade (use the howMany() method). Stop when the user enters no grade. Windows allows you to terminate the input with a CTRL-Z as the first character on a line followed by Enter; Linux uses CTRL-D anywhere without reqiring enter. Instead, you may use a sentinal to stop (See text Section 6.3.1 Reading Data from the User [page 284]).
For example, the interaction might look like this:
Which grade do you want to see> F
F occured 2 times
Which grade do you want to see> B
F occured 1 times
Which grade do you want to see> D
D occured 0 times
Which grade do you want to see>
Operation Completed
As you are writing the program, make sure your program uses correct indentation and defines meaningful variable names.
What I have done so far is:
import java.util.Scanner;
import java.io.File;
class Grades {
private int[] grade;
int []grades = new int [4];
public Grades(int maxGrades){
}
public void addGrade(int grade){
}
public void numGrades(){
}
public String letterGrade(int gradeValue){
String gradeLetter="F";
if(gradeValue>=90 && gradeValue<=100){
gradeLetter = "A";
}
if(gradeValue>=80 && gradeValue<90){
gradeLetter = "B";
}
if(gradeValue>=70 && gradeValue<80){
gradeLetter = "C";
}
if(gradeValue>=60 && gradeValue<70){
gradeLetter = "D";
}
if(gradeValue>=50 && gradeValue<60){
gradeLetter = "E";
}
return gradeLetter;
}
public int howMany(String gradeInLetter){
int noOfStudents=0;
noOfStudents++;
return noOfStudents;
}
public String toString(){
return ;
}
}
public class Homework {
public static void main (String[]args) throws Exception {
File inputFile = new File( "quizgrades.txt" );
Scanner scan = new Scanner( inputFile ) ;
int []grade = new int [6];
grade[0] = scan.nextInt();
grade[1] = scan.nextInt();
grade[2] = scan.nextInt();
grade[3] = scan.nextInt();
grade[4] = scan.nextInt();
grade[5] = scan.nextInt();
for( int i=0; i < grade.length; i ++){
System.out.println (i + grade[i] );
}
}
}

