59.0k views
3 votes
QUESTION 1 : To encourage students, Harvinder High School has decided to award each student a bookstore credit that is 10 times the student’s grade point average. For example, if a student had a 3.2 grade point average then that student receives a $32 credit. - Create a class that prompts a student for a name and grade point average, and then passes the values to a method that displays a descriptive message. The message uses the student’s name, echoes the GPA, and computes and displays the credit. QUESTION 2 : Students at Harvinder have been asked to create a Geometry Program. - Create a class named Rectangle with two fields: length and width. Create a constructor to set the length and width to user-specified values. Write get and set methods for the variables, as well as a method getArea that returns the area of a rectangle, and a method getPerimeter that returns the perimeter of a rectangle. Call your class Rectangle.java. - Write a program TestRectangle.java that creates two rectangles, one with values 3 and 4, and one with values 7 and 5. The program then displays the length, width area and perimeter of each rectangle by calling methods. Do not do any calculations in this program.

User Cen
by
8.2k points

1 Answer

2 votes

Final answer:

For Question 1, create a class that prompts a student for their name and GPA, then displays a message and computes the credit. For Question 2, create a Rectangle class with methods to calculate area and perimeter.

Step-by-step explanation:

For Question 1, you can create a class that prompts a student for their name and grade point average. The values can then be passed to a method that displays a descriptive message using the student's name and GPA. The credit can be computed by multiplying the GPA by 10 and displaying the result.

For Question 2, you can create a class named Rectangle with fields for length and width. Use a constructor to set the values of length and width to user-specified values. Write get and set methods for the variables, as well as methods to calculate and return the area and perimeter of the rectangle. In the TestRectangle class, create two Rectangle objects with different dimensions and call the appropriate methods to display the length, width, area, and perimeter of each rectangle.

User Zeflex
by
8.0k points