Create a program containing and showing random information about name, ID
and status (year, current and cumulative performance) of students from a file
students.txt. This program should process a list of 20 students, filtering those of
them having a name beginning with the same letter (prompt the user to choose
one), who are third year students and have current as well as cumulative
performance above the average of this filtered list. Sort the filtered users
according to their user ID (you can use bubble sort etc). Save the
results in file studentsFilter.txt.
1
Expert's answer
2012-05-22T10:18:01-0400
public class Students implements Comparable{
private String name; private int ID; private String status; private int year;
public Students(String name, int id, String status, int year){ & & this.name = name; & this.ID = id; & this.status = status; & this.year = year; }
public String getName() { & return name; }
public int getID() { & return ID; }
public String getStatus() { & return status; }
public int getYear() { & return year; }
public int compareTo(Object obj){ & Students otherStud = (Students) obj; & if(this.ID < otherStud.getID()) & return -1; & else if (this.ID > otherStud.getID()) & return 1; & return 0; }
Comments
Leave a comment