The program: Write a class called Student (classes start with a capital letter by convention). For reference, you can look at the Date.java demo that is available on the s: drive. Your Student class should have the following:

Data: 5 data fields (which should all be private):

  • a String called name
  • an int called age
  • a char called gender
  • a double called gpa
  • a boolean called onScholarship

Constructors: 2 overloaded constructors (means: same name, different number/type of arguments)

  • A default constructor (receives no arguments) that does not do anything ( just has { } ). Normally, the default constructor would be used to set the data to default values (like John Doe), but I want you to see what values Java will assign if we do not set them ourselves.
  • A parameterized constructor which receives 5 arguments in this order:
    • a String which it will set its name field to
    • an int which it will set its age field to
    • a char which it will set its gender field to
    • a double which it will set its gpa field to
    • a boolean which it will set its onScholarship field to

Methods: 6 methods (which should be public)

  • A method called getAge(). It will receive nothing and return the age.
  • A method called setGPA. It will receive a new GPA (as a double) and set the real GPA to whatever is received. It returns nothing.
  • A method called setOnScholarship. It will receive a boolean value and will set the real onScholarship data field to whatever is passed in. It returns nothing.
  • A method called toString. This method will receive no arguments and return a String with all of the information for whatever Student instance is told to return its toString. The String it should return should be made up of:
< its name>< tab>< its age>< tab>< its gender>< tab>< its gpa>< tab>< onScholarship>
  • A method called onProbation. This method will receive no arguments and return a boolean. It will return true if the Students onScholarship field is true and the Students gpa is < 2.0. Otherwise, it returns false.
  • A method called complain. This method will receive no arguments and return a String. The String will be any complaint that you want your Student instance to say about anything.

Testing your class: I will provide a class called StudentDriver. It will have a main method, so it can be compiled and also run. When using it, be sure it is in the same directory as your Student.java. It should compile if your Student class is set up correctly (methods are defined correctly and the arguments are in the correct order).

Look carefully at StudentDriver.java. It creates instances of Student and then tells them to do things. When you run it, make sure you understand the results.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.