Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the following members functions: (a) Constructor that creates objects of t

ID: 3534624 • Letter: W

Question

Write the following members functions:

(a) Constructor that creates objects of the student class.

(b) read that prompts the user to enter from the keyboard student name, age and gpa.

To terminate reading the user should enter the EOF (ctrl-D in Unix and Ctrl-Z in

DOS).

(c) show that displays on the screen student name, age and gpa.

(d) writefile that writes a record (name, age, gpa) into the file student.dat.

(e) getgpa that returns gpa of the student.

(f) readfile that reads the student record from the file student.dat .


Write a main program that demonstrates the work with this class. Declare all

necessary objects and variables. Using read and writefile create the student.dat.


After closing the file student.dat reopen it for reading. Read and display all students

from the file and compute and display the average gpa for all of them.

Explanation / Answer

public class Student{ private String name; private int age; private double gpa; private char [] courseGrade; private static int count = 0; public Student(String name, int age){ this.name = name; this.age = age; gpa = 0; courseGrade = null; } public String getName(){ return name; } public int getAge(){ return age; } public double getGpa(){ return gpa; } public int getCount(){ return count; } public void setGrades(char [] grades){ courseGrade = new char [grades.length]; for (int i = 0; i