The data fields A private String data field for the students
Solution
UML
class Student   
 - private String studentName;
 - private String V_Number;
 - private double GPA;
 + public Student()    }
 + public Student(String studentName,String V_Number,double GPA)   
 +public void setStudentName(String name) //set methods
 +public void setV_Number(String V)
 + public void setGPA(double gpa)
 + public String getStudentname()   
 + public String getV_Number()
 + public double getGPA()
 + public String toString()
import java.util.*;
 import java.lang.*;
 import java.io.*;
class Student   
 {
    private String studentName;
    private String V_Number;
    private double GPA;
    public Student() //default constructor
    {
        this.studentName=\"John Doe\";
        this.V_Number=\"V00000000\";
        this.GPA=4.0;
    }
    public Student(String studentName,String V_Number,double GPA) parameterized constructor
    {
        this.studentName = studentName;
        this.V_Number = V_Number;
        this.GPA = GPA;
    }
    public void setStudentName(String name) //set methods
    {
        studentName=name;
    }
    public void setV_Number(String V)
    {
        V_Number = V;
    }
    public void setGPA(double gpa)
    {
        if(gpa >0 && gpa<4) //check for GPA range
        GPA=gpa;
        else
        System.out.println(\"GPA must be between 0.0 and 4.0\");
    }
    public String getStudentname() //get methods
    {
        return studentName;
    }
    public String getV_Number()
    {
        return V_Number;
       
    }
    public double getGPA()
    {
        return GPA;
    }
    public String toString() // toString() method
 {
 return studentName+\" \"+V_Number+\" \"+GPA;
 }
 }
class TestStudent
 {
    public static void main (String[] args) throws java.lang.Exception
    {
        Student s1 = new Student();
        System.out.println(\"The name of the student s1 is \" +s1.getStudentname());
        System.out.println(\"The V_Number of the student s1 is \" +s1.getV_Number());
        System.out.println(\"The GPA of the student s1 is \"+ s1.getGPA());
       
        Student s2 =new Student(\"Linda Smith\",\"V00123456\",2.8);
        System.out.println(\"Student s2 is \" +s2.toString());
       
        s2.setGPA(-3.1);
        s2.setGPA(3.2);
        System.out.println(\"Student s2 is \" +s2.toString());
       
    }
 }
output:
Success time: 0.05 memory: 711168 signal:0


