Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is my specific instruction. so I want you to make a new class called StudentsService in the com.sait.itsc315.services package AND modify AppDriver . I
This is my specific instruction. so I want you to make a new class called StudentsService in the com.sait.itsc315.services package AND modify AppDriver. I will attach my appdriver, student, students class below. Thank you!
AppDriver.javapackage com.sait.itsc315.application;
import java.io.*;
import com.sait.itsc315.problemdomain.*;
public class AppDriver {
/**
* Entry point for program.
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
Students students = new Students();
// Create instance of StudentsService
// Print "Honor Students: "
// Loop through honor students
// Print each students information
// Print "Declining Students: "
// Loop through honor students
// Print each students information
}
}
Student.java
package com.sait.itsc315.problemdomain;
public class Student {
private int id;
private String name;
private double gpa;
/**
* Constructor for a student.
* @param id Student's ID
* @param name Name of student.
* @param gpa Student's GPA.
*/
public Student(int id, String name, double gpa) {
this.id = id;
this.name = name;
this.gpa = gpa;
}
/**
* @return the id
*/
public int getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the gpa
*/
public double getGpa() {
return gpa;
}
/**
* @param gpa the gpa to set
*/
public void setGpa(double gpa) {
this.gpa = gpa;
}
public String toString() {
return String.format("%d - %s - %.2f", this.id, this.name, this.gpa);
}
}
Students.java
package com.sait.itsc315.problemdomain;
import java.io.*;
import java.util.*;
public class Students {
public static final String TEXT_FILE = "res/students.csv";
private ArrayList students;
public Students() throws IOException {
this.students = new ArrayList<>();
this.loadFromTextFile();
}
/**
* Loads students from text file.
* @throws IOException
*/
private void loadFromTextFile() throws IOException {
BufferedReader br = new BufferedReader(new FileReader(TEXT_FILE));
String line = br.readLine();
while (line != null) {
String[] parts = line.split(",");
int id = Integer.parseInt(parts[0]);
String name = parts[1];
double gpa = Double.parseDouble(parts[2]);
Student student = new Student(id, name, gpa);
this.students.add(student);
line = br.readLine();
}
}
/**
* Gets the students.
* @return List of students.
*/
public ArrayList getStudents() {
return this.students;
}
}
Instructions 1. Create a new class called Students Service and place it in the com.sait.itsc315.services package. The class will have a: Constructor that takes in a Students object and stores it in a field. Method called getHonorStudents that filters the students with a GPA greater than or equal to 3.8 and returns an ArrayList containing the found student objects. Method called getDecliningStudents that filters the students with a GPA less than or equal to 2.0 and returns an ArrayList containing the found Student objects. 2. Modify the AppDriver so it creates a Students Service object and displays both the honor and declining students (as separate lists). Notes You CANNOT modify the Student or Students classes to complete this lab exercise.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
StudentsService in the comsaititsc315services package and modify the AppDriver class accordingly Her...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