Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment 3 Direction: Submit the typed source code. Parallelogram For this assignment, you will create a Parallelogram class. A parallelogram is a four-sided shapes whose

Assignment 3 Direction: Submit the typed source code. Parallelogram For this assignment, you will create a Parallelogram class. A parallelogram is a four-sided shapes whose opposite sides are parallel and opposites angles are equal (hence opposite sides are equal). The four (4) types of parallelograms and their properties are listed below. Regular Rhombus Square Rectangle Adjacent sides are not equal Adjacent sides are equal Adjacent sides are equal Adjacent sides are not equal No right angles No right angles All right angles All right angles The Parallelogram class should have: Public double field named length. Public double field named width. Public double field named angle. Public string field named type. Public default constructor that assigns 1 to both length and width, 90 to angle, and square to type. Public overloaded constructor that takes two (2) double parameters. The parameters should be assigned to length and width. Furthermore, angle should be assigned 90. Depending on the values of length and width, type should be assigned either square or rectangle. Public overloaded constructor that takes three (3) double parameters. The parameters should be assigned to length, width and angle. Depending on the values of length, width and angle, type should be assigned either square or rectangle or rhombus or regular. Public double method named Perimeter() that takes no parameters. It should return the perimeter of the parallelogram. Public string method named ToString() that takes no parameters. It should return a string of the following format: type(length, width, angle) In the main function, you should create a Parallelogram object for each type of parallelogram. Then display the information of each object by calling the ToString() and Perimeter() methods. When you are displaying the information, display them on the same line with a label before the perimeter to identify it, and format the display so that it will be uniformly spaced. The following is an example of a possible output: square(1.0,1.0,90.0) perimeter: 4.0 rectangle(5.0,8.0,90.0) perimeter: 26.0 regular(6.0,12.0,45.0) perimeter: 36.0 rhombus(10.0,10.0,60.0) perimeter: 40.0 Extra Credit Add the following to the class: Public double method named Area() that takes no parameters. It should return the area of the parallelogram. Modify the main function to display the area of each parallelogram. Round the areas to one decimal place. The following is the modified output of the previous example: square(1.0,1.0,90.0) perimeter: 4.0 area: 1.0 rectangle(5.0,8.0,90.0) perimeter: 26.0 area: 40.0 regular(6.0,12.0,45.0) perimeter: 36.0 area: 50.9 rhombus(10.0,10.0,60.0) perimeter: 40.0 area: 86.6 Extra Credit Add the following to the class: Public double method named MajorDiagonal() that takes no parameters. It should return the length of the diagonal of opposite the larger angle of the parallelogram. Public double method named MinorDiagonal() that takes no parameters. It should return the length of the diagonal of opposite the smaller angle of the parallelogram. Modify the main function to display as well as the major and minor diagonal of each parallelogram. Round the lengths of the diagonals to one decimal place. The following is the modified output of the previous example: square(1.0,1.0,90.0) perimeter: 4.0 minor: 1.4 major: 1.4 rectangle(5.0,8.0,90.0) perimeter: 26.0 minor: 9.4 major: 9.4 regular(6.0,12.0,45.0) perimeter: 36.0 minor: 8.8 major: 16.8 rhombus(10.0,10.0,60.0) perimeter: 40.0 minor: 10.0 major: 17.3

C++

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions