CS 1073 Winter  Hw#3  Submit online   only  your  source code files (extension java), thru Desire to Learn. Ex#1: Write a class called  Student  that represents a typical student with the  attributes:  name, address, major,  GPA and the operations: setName( ), getName( ), setAddress(), getAdrdress(), setMajor( ), getMajor( ), computeGPA( ),  getGPA(). Parameters passing should be set  according  based on getting or setting a  given attribute.   To compute the GPA, generate a random float number between 0.5 and 4.5.  Include two constructors, the first takes a name, address, and major and calls computeGPA to set the GPA. The second only takes a name and address and sets the major to “Undeclared”. It should also call  computeGPA to set the GPA. Write a short driver to test all the above methods and constructors with at least at least 4 students. Here is a sample of input/output  (use “DecimalFormat…” or something similar to format the GPA) Name: Jessica  Brown Address: 500 Cuyahoga  Street, Saint John Major: Computer Science GPA: 2,673 Name: Dan Boulder Address: 54 Queens Blvd., Quispamsis Major: Undeclared GPA: 3,653 Name: Sarah Al-Kaabi Address:  135 University Av., Saint John Major: Business  and History GPA: 1,194 Name: Shin Yu Address: 16  Dale Dr. Major:  Philosophy GPA: 2,578

In this assignment, you are asked to create a class called “Student” that represents a typical student. This class should have the following attributes: name, address, major, and GPA. Additionally, the class should have the following operations: setName(), getName(), setAddress(), getAddress(), setMajor(), getMajor(), computeGPA(), and getGPA().

The parameters for these operations should be set according to whether you are getting or setting a given attribute. For example, if you are setting the name of a student, the parameter for the setName() operation should be the new name of the student.

To compute the GPA, you should generate a random float number between 0.5 and 4.5. This can be done using a random number generator. Once you have generated this random number, you can use it to set the GPA attribute of the student.

The Student class should also have two constructors. The first constructor should take a name, address, and major as parameters. This constructor should call the computeGPA() operation to set the GPA of the student. The second constructor should only take a name and address as parameters. In this case, the major should be set to “Undeclared” and the computeGPA() operation should be called to set the GPA of the student.

Finally, you should write a short driver program to test all the methods and constructors of the Student class. The driver program should create at least four instances of the Student class and use the various methods and constructors to set and retrieve their attributes.

Here is a sample of the expected input and output:

Name: Jessica Brown
Address: 500 Cuyahoga Street, Saint John
Major: Computer Science
GPA: 2.673

Name: Dan Boulder
Address: 54 Queens Blvd., Quispamsis
Major: Undeclared
GPA: 3.653

Name: Sarah Al-Kaabi
Address: 135 University Av., Saint John
Major: Business and History
GPA: 1.194

Name: Shin Yu
Address: 16 Dale Dr.
Major: Philosophy
GPA: 2.578

To format the GPA as shown in the sample output, you can use the DecimalFormat class or a similar approach.

Make sure to submit your solution online by uploading only the source code files with the .java extension through Desire2Learn.

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.


Click Here to Make an Order Click Here to Hire a Writer