Question: (JAVA) An academic advisor wants a program that will compute a student GPA by reading a file that contains the name of the courses taken,
(JAVA) An academic advisor wants a program that will compute a student GPA by reading a file that contains the name of the courses taken, credit hours for each course, and grades earned from each course. The program will take, as run-time parameters, the folder directory where the grades file is stored and the first and last name of the student. For this testing your program, use the posted grades file called grade/Irving-Whitewood.cvs
To complete this assignment, we will use class Student.java completed from Chapter 10. The purpose for this is to reuse functionality we have already created. Create a new java file, called MyStudent.java that inherits from the Student class. Inside this new file, do the following:
1. Static properties and behaviors a. Create a private static ArrayList of courses private static ArrayList
You need to implement code that creates a Course object and adds that object to the courseList.
3. Non-static properties and behaviors a. Create a public constructor that takes two Strings public MyStudent(String fname, String lname);
(implementation details explained below):
i. Determine the number of courses from the size of the courseList.
ii. Call super(fname, lname, numberOfCourses)
b. A public method to compute GPA use the String toString() method (implementation details explained below):
i. For each element in courseList
1. get courseName, creditHours, and letterGrade from the element 2. Call super.createCourse(courseName, creditHours, letterGrade) to create a course
ii. return super.toString() to get the output
Inside your ComputeStudentGPAProgram.java, write a main method that serves as the main launching code. This program will read the file (grade/Irving-Whitewood.cvs) that contains the grades for a student and the first and last name of the student. The program determines the GPA for the student.
Here, you will read the csv file (grade/Irving-Whitewood.cvs) to determine the students GPA. For each line in the file, you will need store this information by calling method addCourse() from class MyStudent. Once you have completed reading the file, close the file, and then proceed to do the following:
invoke the toString() method of this object inside a System.out.println statement
The output of your code will be:
Output: Student {firstname}, {lastname} has a {GPA value} GPA
Example: John Doe has a 3.4 GPA
NOTE
You will be provided with a file grade/Irving-Whitewood.cvs. Note that you cannot hardcode the first name and last name into your program directly. Your program MUST read the filename during the code execution.
The structure of file Irving-Whitewood.cvs is:
CourseName1,creditHours,grade
CourseName2,creditHours,grade
CourseName3,creditHours,grade
CourseName4,creditHours,grade
CourseName5,creditHours,grade
Example:
Calculus,4,A
Physics,4,A
Computer Science,4,B
English,3,C
AmericanHistory,2,B
Inside your ComputeStudentGPAProgram, you will need to use a mechanism to parse each line. While there are a variety ways to accomplish this, the String.split() method is the most feasible.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
