C++
7.26 LAB: Triangle area comparison (classes)
Given class Triangle (in files Triangle.h and Triangle.cpp), complete main() to read and set the base and height of triangle1 and of triangle2, determine which triangle's area is smaller, and output that triangle's info, making use of Triangle's relevant member functions.
Ex: If the input is:
3.0 4.0
4.0 5.0
where 3.0 is triangle1's base, 4.0 is triangle1's height, 4.0 is triangle2's base, and 5.0 is triangle2's height, the output is:
Triangle with smaller area:
Base: 3.00
Height: 4.00
Area: 6.00

Respuesta :

Apply the following formula to the area calculation inside the get Area method.

Calculate area of a triangle?

Area is equal to 0.5 * base * height; user input is requested for both triangles.

Check the areas of the two triangles and print the data for the bigger triangle.

/ / Triangle.java

Triangle public school

double base in private;

double height in private

Public void setBase(double base)

if this.base = base;

}void public setHeight(double height)

if this.height = height;

}

getArea() on a double is public.

recalculate 0.5 * base * height;

}

the public void printInfo()

System.out.printf ('Base:%.2f', 'base');

Height:%.2fn; System.out.printf("Height:%.2fn", height);

System.out.printf ("Area:%.2f", "getArea()")

}

}.

To learn more about Area of a triangle refer to:

https://brainly.com/question/17335144

#SPJ4

ACCESS MORE
EDU ACCESS
Universidad de Mexico