Question: Make a complete Java program as follow: Make two java classes: The first class represents a student and must be named using your first and

Make a complete Java program as follow:

  1. Make two java classes:
    1. The first class represents a student and must be named using your first and last name.
    2. The second class must be named as "Main"with the main method.
  2. Perform the following in the first class:
    1. Make three private instance variables to store first name, last name and GPA. Do not assign any values to the variables in this step!
    2. Make a constructer without parameters to initialize all the instance variables to default values (0 for numbers and "" for a string).
    3. Make a constructor that can take the first and last name as parameters. Assign the parameters' values to the two instance variables you created earlier (first and last name).
    4. Create a getName() method to returnthe first and last name. You must return the first and last name in a single string using a plus sign. You must have a space between the first name and last name.
    5. Create setGPA() and getGPA() methods to store and return your GPA, respectively.
  3. Perform the following in the main class:
    1. Create a new object of your first class and pass your first and last name as two parameters.
    2. Call the getName() method and store the result in a string variable called myFullName.
    3. Print your full name using the string variable myFullName.
    4. Set your GPA using the setGPA() method.
    5. Print your GPA using the getGPA() method.

Note:

  • Your answer should have the code as text as well as the screenshot of the program output (using your own name) as a part of your answer. Otherwise, zero marks will be awarded.

Typical run of the program

Make a complete Java program as follow:Make two java classes:The first class

Compile Messages jGRASP Messages Run 1/0 Interactions End jGRASP exec: java Main Clear My name is Khaled Saleh My GPA is 3.2 Help -jGRASP: operation complete. L

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!