26 lines
528 B
C++
26 lines
528 B
C++
#include "Triangle.h"
|
|
#include <iostream>
|
|
#include <iomanip>
|
|
#include <math.h>
|
|
|
|
using namespace std;
|
|
|
|
void Triangle::SetBase(double userBase) {
|
|
base = userBase;
|
|
}
|
|
|
|
void Triangle::SetHeight(double userHeight) {
|
|
height = userHeight;
|
|
}
|
|
|
|
double Triangle::GetArea() const {
|
|
return 0.5 * base * height;
|
|
}
|
|
|
|
void Triangle::PrintInfo() const {
|
|
cout << fixed << setprecision(2);
|
|
cout << "Base: " << base << endl;
|
|
cout << "Height: " << height << endl;
|
|
cout << "Area: " << round(GetArea() * 100.0f) / 100.0f << endl;
|
|
}
|