Question: USE C++ Step 1: Create a Triangle class. Create your Triangle class header and implementation files and the main program file Include 2 data members

USE C++

Step 1: Create a Triangle class. Create your Triangle class header and implementation files and the main program file

  • Include 2 data members
    • base, height
  • Include the following methods
    • Constructor that accepts the base and height as arguments
    • Create a member function to set the base
    • Create a member function to set the height
    • Calculate Area (calculate base x height)
    • Calculate perimeter
  • Overload the Addition operator (+) as a non member function
    • The overloaded + operator should separately add the base data members and the height data members
  • Overload the Subtraction operator (-) as a member function
    • The overloaded - operator should separately subtract the base data members and the height data members
      • The - operator should set the value to zero for either data member if the calculation results in a negative
    • Overload the equivalence operator (==) as a non member function
      • Equivalence should be defined as the area of the two objects being equal
    • Overload the greater than operator (>) as a member function
      • Greater than should be defined as the area of one object being greater than the other
    • Overload the increment operator (++) as a member function
      • Overload the increment operator as a postfix operator
      • The overloaded ++ operator should increment the base and height data members by 1

Step 2: Create a program to do the following

  • Create 2 Triangle objects using the constructor
  • Create a User Menu with the following options
    1. Update the data in Triangle Object 1 and output the resulting area and perimeter
    2. Update the data in Triangle Object 2 and output the resulting area and perimeter
    3. Increment one of the 2 Triangle objects
    4. Add the 2 objects and output the result
    5. Subtract the 2 objects and output the result
    6. Determine if the first triangle object is greater than the second

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!