Hi I am having trouble with this program I am trying to write. So far I have this:
#include <cmath>
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double sideA, sideB, sideC; //Define the sides before area, perimeter, and s, because area, perimeter, and s, all stem from the sides.
//Also because they are not given numerical values necessary to plug into the forementioned equations.
double area, perimeter, semiperimeter;
cout << "Sample Run 1: " << endl;
cout << endl;
cout << "Enter the lengths of the sides of a triangle> ";
cin >> sideA >> sideB >> sideC;
perimeter = sideA + sideB + sideC; //This block is placed after cin
semiperimeter = perimeter/2; //This block is placed after cin
area = sqrt(semiperimeter*(semiperimeter-sideA)*(semiperimeter-sideB)*(semiperimeter-sideC)); //This block is placed after cin
cout << endl;
cout << "The sides of the triangle are: " << endl;
cout << fixed; //place before setprecsion to identify where the "fixed" command will begin.
cout << " A = " << setprecision(4) << left << sideA << ";"; // setprecision(#) applies to the certain numbers you want behind the decimal. Left pushes the input leftmost
//so that numbers can trail/follow the input.
cout << " B = " << setprecision(4) << left << sideB << ";";
cout << " C = " << setprecision(4) << left << sideC << endl;
cout << endl;
cout << "Perimeter = " << setprecision(4) << left << perimeter << endl;
cout << "Area = " << setprecision(4) << left << area << endl;
cout << endl;
cout << endl;
//This space is reserved for Sample Run 2
cout << "Sample Run 2: " << endl;
cout << endl;
cout << "Enter the lengths of the sides of a triangle> ";
cin >> sideA >> sideB >> sideC;
perimeter = sideA + sideB + sideC; //This block is placed after cin
semiperimeter = perimeter/2; //This block is placed after cin
area = sqrt(semiperimeter*(semiperimeter-sideA)*(semiperimeter-sideB)*(semiperimeter-sideC)); //This block is placed after cin
cout << endl;
cout << "The sides of the triangle are: " << endl;
cout << " A = " << setprecision(4) << left << sideA << ";";
cout << " B = " << setprecision(4) << left << sideB << ";";
cout << " C = " << setprecision(4) << left << sideC << endl;
cout << endl;
cout << "Perimeter = " << setprecision(4) << left << perimeter << endl; //
cout << "Area = " << setprecision(4) << left << area << endl;
system("pause"); // Prevents program from instantly shutting down / crashing
return 0;
}
But I need the program to output this:
Sample Run 1:
Enter the lengths of the sides of a triangle> 7.5 4.5 6
Triangle Program Report
=======================================
The sides of the triangle are:
A = 7.5000; B = 4.5000; C = 6.0000
Perimeter = 18.0000
Area = 13.5000
Classification:
Right: Y
Isosceles: N
Scalene: Y
Equilateral: N
----------------------------------------
Sample Run 2:
Enter the lengths of the sides of a triangle> 1.0 2.0 5.0
Triangle Program Report
=======================================
*** 1.0000, 2.0000, and 5.0000 cannot form the sides of a triangle ***
----------------------------------------
Sample Run 3:
Enter the lengths of the sides of a triangle> 4.1 4.1 5.3
Triangle Program Report
=======================================
The sides of the triangle are:
A = 4.1000; B = 4.1000; C = 5.3000
Perimeter = 13.5000
Area = 8.2905
Classification:
Right: N
Isosceles: Y
Scalene: N
Equilateral: N
----------------------------------------
Thank you in advance. I am not looking for the answer. I just really need help on this. I am lost