Question
package grades; //D.Lopes //9.3.18 //Grade HW Assignment public class Grade { //data variables private String year; private String course; private char grade; //default constructor public
package grades;
//D.Lopes //9.3.18 //Grade HW Assignment
public class Grade { //data variables private String year; private String course; private char grade; //default constructor public Grade(){ year = "2010-11"; course = "Art-02"; grade = 'A'; } //constructor public Grade(String year, String course, char grade){ this.year = year; this.course = course; this.grade = grade; } //getters and setters for course public String getCourse() { return course; } public void setCourse(String course) { this.course = course; }
//getters and setters for grade public char getGrade() { return grade; }
public void setGrade(char grade) { this.grade = grade; }
//setters and getters for year public String getYear() { return year; }
public void setYear(String year) { this.year = year; } //toString method @Override public String toString() { return "Grade [Year=" + year + ", Course=" + course + ", Grade=" + grade + "]"; } //equals method public boolean equals(Grade obj) { return (this.year.equals(obj.getYear()) && this.course.equals(obj.getCourse()) && grade == obj.getGrade()); } }//end class
package grades;
import java.io.File; import java.io.FileNotFoundException; import java.util.HashMap; import java.util.Scanner;
public class GradeDemo { public static void studentsPerYear(Grade[] g, int n, String s) { for(int i = 0; i
String line = input.nextLine(); String fields[] = line.split(","); grades[n] = new Grade(fields[0], fields[1], fields[2].charAt(0)); System.out.println(grades[n]); n++; }//end while //Finds the average grade for a course System.out.println("Averae grade in CSPC-39: " + averageGrade(grades, n, "CSPC-39")); //Finds the number of students per year for a specific course studentsPerYear(grades, n, "CSPC-39"); } }
This is what the first few rows look like, I can't upload a file. It goes from 2010-11 to 2015-16, the file has 413,940 rows. Grades are A, B, C, D and F. The classes are all different.
Attached is a csv file that contains all of the grades for all of the students at Merced College from 2010-2016. Your task is to create a class to hold a record for this file. Then make a Test program to read in the data from the file into an Array of Objects. For your Grade object class make the following data variables and methods: .String year String course char grade . make 2 constructors; the default constructor and another constructor that take in 3 parameters to set your data variables make the setters, getters, toString, and equals methods. Make a test class that will read in the data from the following file into an array of Grade objects. You are then to make methods in your test class to answer 2 of the following questions What is the average grade in CPSC-39 for each of the years, for all of the students in that year? Just count the letter grades A, B, C, D, F What is the average number of students in a CPSC-39 class? Which computer Science Class has the highest amount of A's? (Computer Science classes have a course that contains the letters CPSC you can hard code the names of the classes in your code)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started