Hi, I was asked to write a class that represents a Student

The Student class has the following attributes:

first name  String  // May be 2 words:  Mary Ann
last name   String  // May be 2 words: Smith Jones
student ID number   String
gpa     double  // Range 0.0 to 4.0 inclusive

It has these six public methods. No other public methods.
1.Constructor with 4 parameters: first name, last name, gpa, ID number
Make sure to validate the gpa as described in the mutator method for the gpa below.
2.Accessor method for gpa
3.Accessor method for ID number
4.A getName( ) method that returns a String structured like this: Wilson, Mary Ann
that is: last name, followed by a comma and a space and then first name.
5.A mutator method that lets the client change the gpa. It must verify the gpa is in the range 0.0 to 4.0 (inclusive). If it is not valid, display an error message indicating the problem and end the program.
6.A toString( ) method that returns a String formatted something like this:

Name: Wilson, Mary Ann
ID number: 12345
GPA: 3.5

This is what I have so far

import.java.util.Scanner;

public class Student
{
    private String fname;
    private String lname;
    private String studentId;
    private double gpa;

public Student(String studentFname,String studentLname,String stuId,double studentGpa)
    {
        fname     = studentFname;
        lname     = studentLname;
        studentId = stuId;
        gpa       = studentGpa;
    }

I am having problems validating the Accesor method for gpa, and also validating the gpa as my teacher has explained

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.