Write a Java class that represents a Student with instance variables name, id, and gpa. Include constructors, accessor, mutator and any facilitator methods you may need.
What will be an ideal response?
```
public class Student
{
private String name;
private String id;
private double gpa;
/** Constructors */
public Student()
{
name = null;
id = null;
gpa = 0.0;
}
public Student(String n, String i, double g)
{
name = n;
id = i;
gpa = g;
}
/** Accessor methods */
public String getName()
{
return name;
}
public String getID()
{
return id;
}
public double getGPA()
{
return gpa;
}
/** Mutator methods */
public void setName(String n)
{
name = n;
}
public void setID(String i)
{
id = i;
}
public void setGPA(double g)
{
if((g >= 0) && (g <= 4))
gpa = g;
}
/** Facilitator methods */
public String toString()
{
return (name + " " + id + " " + gpa);
}
public boolean equals(Student s)
{
return ((name.equalsIgnoreCase(s.name)) && (id.equalsIgnoreCase(s.id)) &&
(s.gpa == gpa));
}
}
```
You might also like to view...
Which of the following is a valid statement in Visual Basic?
(A) Form1.Text = "Revenue" (B) Form1.Caption = "Revenue" (C) btnButton.Text = Push Me (D) Me.Text = "Revenue"
Additional shapes can NOT be added to a SmartArt graphic
Indicate whether the statement is true or false
Often, a tape ____________________ automatically retrieves tape cartridges, which are identified by location or bar code.
Fill in the blank(s) with the appropriate word(s).
A user reports the computer network seems slow. The user's office had one network port available, but the user needed to add more network devices. The user located an older network device that allowed multiple connections. However, the network performance decreased due to collisions. Which of the following explains the cause of this issue?
A. The user connected a bridge B. The user connected a router C. The user connected a switch D. The user connected a hub