Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ using iostream , using namespace std, NO pointers Create a class, Triangle, with the following private attributes: base (float) and height (float). The class

C++ using iostream, using namespace std, NO pointersimage text in transcribed

Create a class, Triangle, with the following private attributes: base (float) and height (float). The class has public set and get methods as well as a public method computeArea) that returns the triangle's area (base * height / 2.0) Write a main program that creates either a vector or an array to hold 5 instances of Triangle. Use a for loop to ask the user for base and height dimensions for each instance and store in the object's appropriate attributes. Write a max function, passing the vector or array as a parameter, to determine which object has the greatest area, returning the index number of that object. Finally, write to the console the base, height, and area of all triangles, each on a separate line. All numbers are to be displayed to two decimal places. Put a comment after the largest one to indicate it is largest. You must use separate source files for each main, max, and class Triangle Sample output: 2.00 x 4.00 has area 4.00 1.00 x 6.00 has area 3.00 2.50 x 4.25 has area 5.31 largest 4.00 x 0.05 has area 0.01 0.99 x 0.99 has area 0.49

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

Inductive Databases And Constraint Based Data Mining

Authors: Saso Dzeroski ,Bart Goethals ,Pance Panov

2010th Edition

1489982175, 978-1489982179

More Books

Students also viewed these Databases questions