Guest User

Untitled

a guest
Dec 14th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. public class Student
  2. {
  3. private String name;
  4. private int age;
  5. private double gpa;
  6.  
  7. public Student(String person, int years, double avg)
  8. {
  9. // initialise instance variables
  10. name = person;
  11. age = years;
  12. gpa = avg;
  13. }
  14.  
  15. public String getName()
  16. {
  17. return name;
  18. }
  19. public int getAge()
  20. {
  21. return age;
  22. }
  23. public double getGPA()
  24. {
  25. return gpa;
  26. }
  27.  
  28. public class Students
  29. {
  30. private ArrayList<Student>students;
  31.  
  32. public Students()
  33. {
  34. // initialise instance variables
  35. students = new ArrayList<Student>();
  36. }
  37. public void add(Student s)
  38. {
  39. students.add(s);
  40. }
  41. public Student readFile() throws IOException
  42. {
  43. // reads data file into ArrayList
  44. String line;
  45. Scanner sc = new Scanner(new File("Students.txt"));
  46. while (sc.hasNextLine()) {
  47. **//code to read file into student array list**
  48. }
  49. sc.close();
  50. }
  51.  
  52. Name0
  53. 22
  54. 1.2
  55. Name1
  56. 22
  57. 2.71
  58. Name2
  59. 19
  60. 3.51
  61. Name3
  62. 18
  63. 3.91
Add Comment
Please, Sign In to add comment