Each command is performed by a method of essentially


import java.util.*;

/**
* Student grade book.
*
* @author put your name here
*/
public class HW3 {

/**
* Test driver.
*
* @param args Unused.
*/
public static void main(String [] args) {

// the class list
TreeMap> classList =
new TreeMap>();

// prompt for and read commands
Scanner input = new Scanner(System.in);
System.out.print("Enter a command: ");
while (input.hasNextLine()) {
String command = input.nextLine();

// if end, done
if (command.equals("end")) {
break;
}

// if addstudent, get name and do it
else if (command.equals("addstudent")) {
System.out.print("Enter student's name: ");
String name = input.nextLine();
addStudent(classList,name);
}

// if removestudent, get name and do it
else if (command.equals("removestudent")) {
System.out.print("Enter student's name: ");
String name = input.nextLine();
removeStudent(classList,name);
}

// if entergrade, get info and do it
else if (command.equals("entergrade")) {
System.out.print("Enter student's name: ");
String name = input.nextLine();
System.out.print("Enter assignment name: ");
String assgn = input.nextLine();
System.out.print("Enter score (int): ");
int score = Integer.parseInt(input.nextLine());
enterGrade(classList,name,assgn,score);
}

// if changegrade, get info and do it
else if (command.equals("changegrade")) {
System.out.print("Enter student's name: ");
String name = input.nextLine();
System.out.print("Enter assignment name: ");
String assgn = input.nextLine();
System.out.print("Enter new score (int): ");
int score = Integer.parseInt(input.nextLine());
changeGrade(classList,name,assgn,score);
}

// if printstudent, get name and do it
else if (command.equals("printstudent")) {
System.out.print("Enter student's name: ");
String name = input.nextLine();
printStudent(classList,name);
}

// if gradestats, get assignment name and do it
else if (command.equals("gradestats")) {
System.out.print("Enter assignment name: ");
String assgn = input.nextLine();
gradeStats(classList,assgn);
}

// otherwise the command is invalid
else {
System.out.println("Invalid command");
}

// print the map so far and prompt for the next command
System.out.println("Map: " + classList);
System.out.print("Enter a command: ");
}
} // end of main method

/**
* Add a student to the class list.
* If there already is a student with the same name, just print an error
* message.
*
* @param list The class list.
* @param name The student's name.
*/
public static void
addStudent(TreeMap> list,
String name) {

} // end of addStudent method

/**
* Remove a student from the class list.
* If the student isn't in the list, just print an error message.
*
* @param list The class list.
* @param name The student's name.
*/
public static void
removeStudent(TreeMap> list,
String name) {

} // end of addStudent method

/**
* Enter a grade on an assignment for a particular student.
* If the student isn't in the class list, just print an error message.
* If the assignment is already in this student's list, just print an error
* message.
* If the score is less than 0 or greater than 100, just print an error
* message.
*
* @param list The class list.
* @param name The student's name.
* @param assgn The assignment name.
* @param score The score.
*/
public static void
enterGrade(TreeMap> list,
String name, String assgn, int score) {

} // end of enterGrade method

/**
* Change the grade on a particular assignment for a particular student.
* If the student isn't in the class list, just print an error message.
* If the assignment isn't in this student's list, just print an error
* message.
* If the score is less than 0 or greater than 100, just print an error
* message.
*
* @param list The class list.
* @param name The student's name.
* @param assgn The assignment name.
* @param score The score.
*/
public static void
changeGrade(TreeMap> list,
String name, String assgn, int score) {

} // end of changeGrade method

/**
* Print the name of the student, all their scores, and their average score.
* If the student isn't in the class list, just print an error message.
*
* @param list The class list.
* @param name The student's name.
*/
public static void
printStudent(TreeMap> list,
String name) {

} // end of printStudent method

/**
* Print min, max and average scores for a particular assignment over all
* the students.
*
* @param list The class list.
* @param assgn The assignment name.
*/
public static void
gradeStats(TreeMap> list,
String assgn) {

} // end of gradeStats method

} // end of HW3 class
The main method prompts the user for various commands to be applied to the class list, and for information for those commands. The commands are:

addstudent - add a new student to the class list
removestudent - remove an existing student from the class list
entergrade - enter a score for a new assignment for a given student
changegrade - change a score for an existing assignment for a given student
printstudent - print the name and all scores for a given student
gradestats - print the min, max and average score for a given assignment over all the students
Each command is performed by a method of essentially the same name. Skeleton code for these methods already exists in the code above, along with appropriate documentation for the methods. Your task is to write code to make the methods do what they are supposed to do.

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Each command is performed by a method of essentially
Reference No:- TGS0134242

Expected delivery within 24 Hours