
Explanation of Solution
a.
Program code:
Student.java
//define a class Student
class Student
{
//declare the class members
private String ID;
private int numberOfCredits;
private int points;
private double gradePoint;
//define the constructor
public Student()
{}
//define the constructor
public Student(String aID, int aNumberOfCredits, int aPoints)
{
//initialize the class members
super();
ID = aID;
numberOfCredits = aNumberOfCredits;
points = aPoints;
//call the method calculateGradePoint()
calculateGradePoint();
}
//define the method getID()
public String getID()
{
//return the value of ID
return ID;
}
//define the method setID()
public void setID(String aID)
{
//set the value of ID
ID = aID;
}
//define the method getNumberOfCredits()
public int getNumberOfCredits()
{
//return the value of numberOfCredits
return numberOfCredits;
}
//define the method setNumberOfCredits()
public void setNumberOfCredits(int aNumberOfCredits)
{
//set the value of numberOfCredits
numberOfCredits = aNumberOfCredits;
}
//define the method getPoints()
public int getPoints()
{
//return the value of points
return points;
}
//define the method setPoints()
public void setPoints(int aPoints)
{
//set the value of points
points = aPoints;
}
//define the method toString()
public String toString()
{
//return the value
return "ID : " + ID + " NumberOfCredits : " + numberOfCredits + " Points : " + points+" Grade Point : "+gradePoint;
}
//define the method calculateGradePoint()
public void calculateGradePoint()
{
//calculate the value of gradePoint
gradePoint=points/(double)numberOfCredits;
}
}
Explanation:
The above snippet of code is used create a class “Student”. The class contain different static methods for store the details of a student. In the code,
- Define a class “Student”
- Define the constructor “Student ()” method.
- Define the constructor “Student ()” method.
- Initialize the class members.
- Call the method “calculateGradePoint()”.
- Define the “getID()” method.
- Return the value of the variable “ID”.
- Define the “setID()” method.
- Set the value of the variable “ID”.
- Define the “getNumberOfCredits()” method.
- Return the value of the variable “NumberOfCredits”...

Trending nowThis is a popular solution!

Chapter 3 Solutions
EBK JAVA PROGRAMMING
- Design and draw a high-level "as-is" process diagram that illustrates a current process related to a product or service offered through the SSDCI.gov database.arrow_forwardCompare last-mile connections for connecting homes and businesses to the Internetarrow_forwardExplain wireless networking standardsarrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning




