Hello, I am currently working on a Java assignment, but I have never come across this phrase before, and my prof. won't get back to me. This is my assignment:
"
Write a class in Java named Student whose UML class diagram is shown below. The default (no-parameter) constructor should initialize the String data members to the empty String( “ “) and the double member to 0.0. The input method should allow users to input the values of the object’s data members using prompted console input. Do not use pop-up dialog boxes for this input! The toString( ) method is important for effective output. Note that in the diagram, private access is denoted with a minus sign ( - ) and public access is denoted with a plus sign ( + ).
Student class
- String name //Student Name
-String id //Student ID (s + 8 digits)
- double gpa //Student GPA (0.0 tp 4.0)
+Student() //Default constructor
+Student(String, String, double) //All parameters contructor
+String toString()
+void input() //Console input of Student object
+void set(String, String, double) //Sets all instance variables
+String getName()
+String getID()
+String getGPA()
"
My code so far:
import java.util.Scanner;
public class Student
{
private String name;
private String id;
private double gpa;
public Student(String n, String i, double g)
{
name = n;
id = i;
gpa = g;
}
public String toString()
{
return( name +
"\ntheir student id is : "+ id +
"\nand their gpa is : "+ gpa);
}
public void input()
{
}
public void set(String n, String i, double g)
{
name = n;
id = i;
gpa =g;
}
public String getName()
{
return name;
}
public String getID()
{
return id;
}
public double getGPA()
{
return gpa;
}
}
Any help as to what it is that I'm supposed to do with the public void input() would be absolutely appreciated.