Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Student
- {
- private String name;
- private int age;
- private double gpa;
- public Student(String person, int years, double avg)
- {
- // initialise instance variables
- name = person;
- age = years;
- gpa = avg;
- }
- public String getName()
- {
- return name;
- }
- public int getAge()
- {
- return age;
- }
- public double getGPA()
- {
- return gpa;
- }
- public class Students
- {
- private ArrayList<Student>students;
- public Students()
- {
- // initialise instance variables
- students = new ArrayList<Student>();
- }
- public void add(Student s)
- {
- students.add(s);
- }
- public Student readFile() throws IOException
- {
- // reads data file into ArrayList
- String line;
- Scanner sc = new Scanner(new File("Students.txt"));
- while (sc.hasNextLine()) {
- **//code to read file into student array list**
- }
- sc.close();
- }
- Name0
- 22
- 1.2
- Name1
- 22
- 2.71
- Name2
- 19
- 3.51
- Name3
- 18
- 3.91
Add Comment
Please, Sign In to add comment