Can someone please help writing this code? Not really good at this stuff. You wi
ID: 3711869 • Letter: C
Question
Can someone please help writing this code? Not really good at this stuff. You will have three different classes in which you will need to label so I know when the next class starts because I will need to submit with three java files. Also, please have comments so I can understand how you did what you did. This is in Java! Thank you for all your help it will be greatly appreciated.
Write classes to represent a student's transcript. You will have 3 classes, a 'course' class that describes a single academic class, a student class to describe a student, and a transcript class to keep the list of classes a student has taken.
Your classes should have the following fields:
course:
prefix (like CS or MATH)
number (like 180)
grade (A,B,C,D,or F)
credit hours
student:
name
id number (WKU id's are too long for an int, so use a 'long' type)
transcript
transcript
courselist - an array of courses (you may assume no more than 50 classes)
number of classes - the actual number of classes completed
The student object should have the following methods (although these might get support from methods in the other classes):
printTranscript() -- display the transcript
getCreditHrs() -- returns the total number of credit hours earned
getUpperHrs() -- returns the total number of upper division hours earned. Upper division courses are those with numbers 300 and highter (CS 180 is NOT upper division, CS 325 IS upper division)
gpa() -- return the student's grade point average.
If you have never calculated a GPA, here is a sketch of how to do it:
for each class
covert grade to numeric value (A->4, B->3, C->2, D->1, F->0)
multiply the numeric grade by the credit hours to give quality points
add quality points to running total
gpa is the running total of quality points divided by the total number of credit hours.
Explanation / Answer
1. Course.java:
public class Course {
String prefix;
int number;
char grade;
int creditHours;
}
2. Transcript.java:
public class Transcript {
Course[] courselist = new Course[100];
int numOfClasses;
}
3. Student.java:
public class Student {
String name;
long idNumber;
Transcript t;
public void printTranscript() {
//Iterating the courselist from the transcript object and printing the course details
for(Course c:t.courselist) {
System.out.println(c.prefix+" "+c.number+" "+c.grade+" "+c.creditHours);
}
}
public int getCreditHrs() {
int creditHrs = 0;
//Iterating the courselist from the transcript object and calculating the credithours
for(Course c:t.courselist) {
creditHrs = creditHrs + c.creditHours;
}
return creditHrs;
}
public int getUpperHrs() {
int upperHrs = 0;
//Iterating the courselist from the transcript object and calculating the upperHours
for(Course c:t.courselist) {
if(c.number>=300) {
upperHrs = upperHrs + c.creditHours;
}
}
return upperHrs;
}
public float gpa() {
int grade = 0;
int qualityPoints;
int totalqualityPoints = 0;
int totalCreditHours = 0;
//Iterating the courselist from the transcript object and calculating the GPA
for(Course c:t.courselist) {
switch(c.grade) {
case 'A':
grade = 4;
break;
case 'B':
grade = 3;
break;
case 'C':
grade = 2;
break;
case 'D':
grade = 1;
break;
case 'F':
grade = 1;
break;
}
totalCreditHours = totalCreditHours + c.creditHours;
qualityPoints = grade * c.creditHours;
totalqualityPoints = totalqualityPoints+qualityPoints;
}
float gpa = totalqualityPoints / totalCreditHours;
return gpa;
}
}