Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in C++ please (The Triangle class) Design a class named Triangle that extends Geometricobject. The class contains the following: Three double data fields named side1,

in C++ please

image text in transcribed

(The Triangle class) Design a class named Triangle that extends Geometricobject. The class contains the following: Three double data fields named side1, side2, and side3 to denote the three sides of the triangle Ano-arg constructor that creates a default triangle with each side equal to 1.0 A constructor that creates a triangle with the specified side1, side2, and side 3 The constant accessor functions for all three data fields A constant function named getArea () that returns the area of this triangle A constant function named getPerimeter() that returns the perimeter of this triangle Draw the UML diagram that involves the classes Triangle and Geometricobject. Geometricobject can be downloaded (header and source file) from the Moodle site. Implement the Triangle class and write a test program that prompts the user to enter the three sides of a triangle, enter a colour and enter 1 or 0 to indicate whether the triangle is filled or not. The program should create a Triangle object with these sides and set the colour and filled properties using the input. The program should then display the area, perimeter, colour, and state true or false to indicate whether it is filled or not. As an example: Input the lengths of the three sides of the triangle: 2.5 4.0 5.5 Enter whether the triangle is filled (1) or not (@): 1 Enter the colour of the triangle: blue You created a blue triangle of area 4.58258 and perimeter 12 was the triangle filled? true Press any key to continue . . Note: let a, b, c be the lengths of the sides of the triangle. The area is given by: Area = P(p a)(p b) (p c) where pis half of the perimeter (p = (a + b + c)/2)

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

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago