Home » Questions » Unexperienced [ Ask a new question ]

Create a class named student. a student has fields for an id number, number of credit hours earned, and number of points earned. (for exampl

Create a class named student. a student has fields for an id number, number of credit hours earned, and number of points earned. (for example, many schools compute grade point averages based on a scale of 4, so a three-credit-hour class in which a student earns an a is worth 12 points.)

Asked by: Guest | Views: 34
Total answers/comments: 1
Guest [Entry]

"public class Student(){

String idNumber;

int hoursEarned, pointsEarned;

public Student(String id){

 hoursEarned = 0;

 pointsEarned = 0;

 idNumer = id;

}

public int getHours(){

 return hoursEarned;

}

public int getPoints(){

 return pointsEarned;

}

public void addHours(int hours){

 hoursEarned += hours;

 addPoints(hours);

}

private void addPoints(int hours){

 int toAdd = SCALE * hours;  //scale would be the desired scale

 pointsEarned += toAdd;

}

}

Hopefully I didn't make any mistakes"