Question
JAVA PLEASE: Instructions: Read the file Student100.text into a LList . An option to do this is : use the overloaded Student constructor that takes
JAVA PLEASE:
Instructions: Read the file "Student100.text" into a LList
An option to do this is : use the overloaded Student constructor that takes a Scanner parameter and builds the Student from data read from the file
After youve successfully read the file, ask the user to input a cutoff GPA value. Go through and remove all of the Students who fall below the cutoff GPA, and print the resulting list of remaining students.
Here is the Student.java file:
import java.util.Scanner; /** * Write a description of class Student here. * Class student represents a student record in a database. * @author (Villarreal) * @version 2/9/2011 */ public class Student { private String firstName, lastName; private double GPA; private int ID; public Student(){ // default constructor firstName = ""; lastName = ""; GPA=0; ID=0; } public Student(String firstName, String lastName, int ID, double GPA){ this.firstName = firstName; this.lastName = lastName; this.ID = ID; this.GPA = GPA; } public Student clone(){ Student copy = new Student(firstName, lastName, ID, GPA); return copy; } public boolean equals(Object other) { Student that = (Student)other; return ((this.ID == that.ID) && (this.GPA == that.GPA) && (this.firstName.equals(that.firstName)) && (this.lastName.equals(that.lastName))); } public String toString(){ return firstName + " " + lastName + ", ID: " + ID + " - GPA: " +GPA; } public String getFirstName(){ return firstName; } public String getLastName(){ return lastName; } public int getID(){ return ID; } public double getGPA(){ return GPA; } public void setFirstName(String firstName){ this.firstName = firstName; } public void setLastName(String lastName){ this.lastName = lastName; } public void setID(int ID){ this.ID = ID; } public void setGPA(double GPA){ this.GPA = GPA; } public void read(Scanner s){ ID = s.nextInt(); firstName = s.next(); lastName = s.next(); GPA = s.nextDouble(); } } LList.java file:
import java.util.LinkedList; public class LList
public void add(T newEntry) // adds newEntry to end of list { list.add(newEntry); } public boolean add(int newPosition, T newEntry){ // inserts newEntry at newPosition int index = newPosition - 1; list.add(index, newEntry); return true; } public T remove(int givenPosition){ // removes item at givenPosition and returns it int index = givenPosition -1 ; return list.remove(index); } public void clear(){ // removes all items from list list.clear(); } public boolean replace(int givenPosition, T newEntry){ // replaces item at givenPosition with newEntry int index = givenPosition - 1; return list.set(index, newEntry)!= null; // return whether an object was actually replaced } public T getEntry(int givenPosition){ // returns item at givenPosition int index = givenPosition - 1; return list.get(index); } public boolean contains(T anEntry){// returns true if anEntry is in list return list.contains(anEntry); } public int getLength(){ // returns number of entries in list return list.size(); } public boolean isEmpty(){ // returns true if list isEmpty return list.isEmpty(); } public Object[] toArray(){ // returns an Object array containing all items in list return list.toArray(); } public String toString(){ // returns an String containing all items in list return list.toString(); } }
and here is what needs to be completed:
StudentListApp.java
/** * Write a description of class Problem3 here. * * @author (your name) * @version (a version number or a date) */ public class StudentListApp { public static void main(String [] args) { // solve the Student List problem here // declare variables System.out.println("Enter the record file name: "); String filename = keyboard.next(); System.out.println("Where would you like the GPA cut off?: "); double gpaCut = keyboard.nextDouble(); } }
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