Create a class having four private double data members -


Assignment

Requirement:

Create a class LastnameFirstnameA4.javaprogram having four private double data members - side1, side2, side3 and side4 storing the measures of sides of the quadrilateral.

Along with the constructor, the member methods in this class include:

lengthCompare() - returns an integer and compares the lengths of the sides.

If all the four sides are equal, you should let the user know that it's a square and go ahead with the other functions (perimeter and area)

If onlytheopposite sides are of same length,let the user know that it's a rectangle and go ahead with the other functions (perimeter and area)

If the sides are different, let the user know that it's a quadrilateral of different side lengths and only execute and print the perimeter function.
(Here, when we find all lengths equal or opposite lengths equal, we assume thatall the interior angles are right angles (?90?^0))

getPerimeter() - returns a double, perimeter of the quadrilateral
getArea() - returns a double, area of the quadrilateral (area only for square or rectangle)
print() - prints information as shown below (shows only 3 types - Square, Rectangle and Quadrilateral and rest of the information such as perimeter and area.)

You can pass arguments in the above functions wherever required.

In the main method of LastnameFirstnameA4.java create the objects of this class and call the function(s) necessary to print the required output as shown in the sample output.

Sample input:

LastnameFirstnameA4 Obj1 = new LastnameFirstnameA4(7, 4.1, 7, 4.1);
LastnameFirstnameA4 Obj2 = new LastnameFirstnameA4(2,2,2,2);
LastnameFirstnameA4 Obj3 = new LastnameFirstnameA4(1, 2, 3, 4);

Sample output:

(7, 4.1, 7, 4.1) is a rectangle
The Perimeter is22.200000000000003
The area is28.699999999999996

(2,2,2,2) is a square
The Perimeter is8.0
The Area is4.0

(1, 2, 3, 4) is a quadrilateral
The Perimeter is 10.0

Program Completed

Note:

1. The program should always print ‘Program Completed' before exiting.
2. Check if your program works properly by using different values for sides of the quadrilateral
3. There is no user input needed for this program.
4. Give comments to increase code readability.
5. Mention the sources used to complete the assignment.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Create a class having four private double data members -
Reference No:- TGS02660054

Expected delivery within 24 Hours