Design and write classes in a class hierarchy to describe different types of geometric shapes. Provide information in the classes in order to compute the area of each of the shapes. Create three separate classes (Triangle, Rectangle, Circle) that are derived from a separate base class (Shape). Write a program that allows a user to create any of the different shape types. Prompt the user to select the shape type and enter the necessary dimensions (i.e. refer to formulas below; rectangle needs width and height, circle needs radius, triangle needs height and base). After the user has finished creating the shape, compute and print out the area.
Use the following formulas for your program:
Triangle:
area = ½ * base * height
Rectangle:
area = width * height
Circle:
area = PI * radius2
Solution Preview
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.
Please let us know the date by which you need help from your tutor or the date and time you wish to have an online tutoring session.
Request Speed
Normal response time: Our most experienced, most successful tutors are provided for maximum expertise and reliability.
Fast response time: Used only for emergencies when speed is the single most important factor.
Why do we ask for this?
We require your email address so that we can send you an email alert when the tutor responds to your message.
We respect your privacy. Your email address will not be used for any other purpose.
You may read our privacy policy for more info.
This is not a free service
You will get a negotiable price quote with no obligation.
Homework Due Date
Please let us know the date by which you need help from your tutor or the date and time you wish to have an online tutoring session.
Request Speed
Normal response time: Our most experienced, most successful tutors are provided for maximum expertise and reliability.
Fast response time: Used only for emergencies when speed is the single most important factor.
Why do we ask for this?
We require your email address so that we can send you an email alert when the tutor responds to your message.
We respect your privacy. Your email address will not be used for any other purpose.
You may read our privacy policy for more info.
This is not a free service
You will get a negotiable price quote with no obligation.
Homework Library
Warning: If you try using the HL in an unethical manner, expect to fail your class. All HL items are old, recycled materials and are therefore not original. We intend them to be used only for the purpose of studying and learning.