Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

// Lab Project 2 // Enter your name: #include #include #include using namespace

ID: 3666163 • Letter: #

Question

// Lab Project 2 // Enter your name: #include #include #include using namespace std; // complete the following three functions // The function InputBaseHeight will read the values for the Base and Height of a Triangle from the keyboard // and pass the Base and Height values back through a reference parameter. void InputBaseHeight( ) // The function TriangleArea will receive the Base and Height values through a value parameter and // return the Area of the Triangle through the function name double TriangleArea ( // Area = 1/2 * Base * Height // The function PrintArea will receive the Area value through a value parameter // and label and print the Area value. void PrintArea (

Explanation / Answer

Program is given below, comments are given in bold letters.

#include<iostream>
using namespace std;

class calculateArea // class for calculate area of triangle
{
   public:
       double base, height, area;
      
       void inputBaseHeight(double &b, double &h) // inputBaseHeight function that take input and return the reference
       {
           cout<<"Enter the base of triangle"<<endl;
           cin>>b;
           cout<<"Enter the height of triangle"<<endl;
           cin>>h;
       }
      
       double TriangleArea() // TriangleArea function will calculate the area and return back
       {
           inputBaseHeight(base, height);
          
           area = ((base*height) / 2);
          
           return area;
       }
      
       void PrintArea(double triangleArea) // PrintArea function take the triangeArea as input and print it
       {
           cout<<"The area of triangle is: "<<triangleArea<<endl;
       }
};

int main()
{
   calculateArea obj1; // object of class
  
   obj1.PrintArea(obj1.TriangleArea());  
}