**This is a 3-part question written exactly as it is shown in the 7th edition of
ID: 644570 • Letter: #
Question
**This is a 3-part question written exactly as it is shown in the 7th edition of Java Programming.**
Thank you for any help.
A) Create a class named Student. 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.) Include methods to assign values to all fields. Student also has a field for grade point average. Include a method to compute the grade point average field by dividing points by credit hours earned. Write methods to display the values in each Student field. Save this class as Student.java
B) Write a class named ShowStudent that instantiates a Student object from the class you created and assigns values to its fields. Compute the Student grade point average, and then display all the values associated with the Student. Save the application as ShowStudent.java
C) Create a constructor for the Student class you created. The constructor should initialize each Student's ID number to 9999, his or her points earned to 12, and credit hours to 3 (resulting in a grade point average of 4.0). Write a program that demonstrates that the constructor works by instantiating an object and displaying the initial values. Save the application as ShowStudent2.java
**This is ONE question, broke up into 3 parts, not 3 seperate questions. As you can see, they are all supposed to work together. Thanks again. Remember, I'm only on ch.4 and I'll reward hansomely to anyone with the "correct" answer.
**PLEASE MAKE SURE THIS WILL RUN IN ECLIPSE LUNA BEFORE SUBMITTING>>>>THANK YOU!!**
Explanation / Answer
Open a file named ShowStudent.java a
class Student
{
private int ID;
private int creditHours;
private int pointsEarned;
double GPA;
public Student()
{
}
public Student(int id,int hrs, int pts)
{
ID=id;
creditHours=hrs;
pointsEarned=pts;
}
public double getGPA()
{
return GPA;
}
public void setGPA()
{
GPA = (double) pointsEarned / creditHours;
}
public void setID(int number)
{
ID = number;
}
public int getID()
{
return ID;
}
public void setCreditHours(int hours)
{
creditHours = hours;
}
public int getCreditHours()
{
return creditHours;
}
public void setPointsEarned(int points)
{
pointsEarned = points;
}
public int getPointsEarned()
{
return pointsEarned;
}
}
public class ShowStudent
{
public static void main(String[] args)
{
// TODO Auto-generated method stub
Student st1=new Student(9999,3,12);
st1.setGPA();
System.out.print("Student ID:"+st1.getID()+" GPA:"+st1.getGPA());
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.