Python Quadrilaterals  Write a program that accepts the dimensions of a quadrilateral and prints its corresponding area and perimeter.   PROGRAM DESIGN You are provided the 2 python files: (1) Quadrilateral.py which contains the parent class Quad and (2) input.py which contains all input mechanisms and conditions that would handle taking in inputs and initializing object instances. You are not allowed to edit these files. The Quad class represents a quadrilateral, which is a four-sided polygon. It has the following attributes: top, bottom, left and right. These attributes have the float datatype. Aside from these attributes, the constructor and printResults are also found within class Quad. Quad - top - bottom

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Python Quadrilaterals 


Write a program that accepts the dimensions of a quadrilateral and prints its
corresponding area and perimeter.

 


PROGRAM DESIGN
You are provided the 2 python files: (1) Quadrilateral.py which contains the parent class
Quad and (2) input.py which contains all input mechanisms and conditions that would
handle taking in inputs and initializing object instances. You are not allowed to edit these
files.
The Quad class represents a quadrilateral, which is a four-sided polygon. It has the
following attributes: top, bottom, left and right. These attributes have the float datatype.
Aside from these attributes, the constructor and printResults are also found within class
Quad.


Quad
- top
- bottom
- left
- right
+ printResults()


Calling Quad’s printResults() – prints the area and perimeter of a rectangle. Given that
the top and bottom dimensions are equal – and the left and right dimension are equal as
well. – Otherwise, it prints ‘Syntax Error!’.


Your task is to create another file with the file name as otherQuads.py. This file contains
a class called otherQuads. This is a child-class of Quad, therefore, otherQuads should
inherit Quad’s attributes – use super(). However, the otherQuads class has a lone
unique attribute called height. This attribute too, should have the float datatype.
Similar to its parent, this class should also contain its respective constructor, and
printResults() methods. However, otherQuads’ printResults() method should calculate
and print the area and perimeter results for a parallelogram or a trapezoid.


otherQuads
- top
- bottom
- left
- right
- height
+ printResults()


Take note of the features of the shapes: both parallelogram and trapezoid have a height.
But a parallelogram has equal top and bottom sides, and equal left and right sides, but
not necessarily have equal side lengths (all four sides). Trapezoids do not have equal side
lengths!


INPUT
The input would be a string that contains the side lengths of a given quadrilateral in this
order: top, bottom, left, and right. If the number of elements in the string is not 4, then
it is assumed that the 5th element would be the height of either a parallelogram or a
trapezoid. Also take note that all numbers in this activity have the float data type. These
data are separated by spaces. Inputs and object declarations are already in the inputs.py
file, again your tasked only to create the otherQuads class in otherQuads.py.

 


OUTPUT
Once the user enters the input, the program should be print the area followed by the
perimeter of a given quadrilateral. Note that the area and perimeter results should be
separated by a space and be calculated. Also take note that results should only have 1
floating point (one decimal point).
However, if the user decides to enter less or more than the required number of
dimensions/input numbers, then the program should output “Syntax Error!”
Note: Only test cases involving syntax errors, parallelograms and trapezoids are scored
for this activity. Test cases involving rectangles are there just to prove that Quad, and its
method printResults() works.

 


SAMPLE INPUT

2 2 4 4 5
2 1 2 1 0 1
2 4 5 6 7
1 2 3 4 5
7 7 2 2 12
5 5 3 3 7 

SAMPLE OUTPUT

10.0 12.0
Syntax Error!
21.0 17.0
7.5 10.0
84.0 18.0
35.0 16.0

Shape:
Parallelogram
Trapezoid
Area
bottom
top + bottom
*
height
* height
Perimeter
(2* (top + left))
top + bottom + left + right
Transcribed Image Text:Shape: Parallelogram Trapezoid Area bottom top + bottom * height * height Perimeter (2* (top + left)) top + bottom + left + right
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education