Answered step by step
Verified Expert Solution
Question
1 Approved Answer
c++ ----------- Question 01 Create a class, Triangle, with the following private attributes: base (float) and height (float) The class has public set and get
c++ -----------
Question 01 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.49Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started