I do not understand how to use enumeration types. I understand what they are, but I don't quite get their purpose. I have made a program that inputs three sides of a triangle and outputs whether or not they are isosceles, scalene, or equilateral. I'm suppose to incorporate the enumeration type somewhere, but don't get where and how to use them. Any help would be appreciated.
// h8p466x1.cpp : Defines the entry point for the console application.
//
include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
include
using namespace std;
enum triangleType {scalene, isosceles, equilateral, noTriangle};
void triangleShape(double x, double y, double z);
int main()
{
double x, y, z;
cout << "Please enter the three sides of a triangle:" << endl;
cout << "Enter side 1: ";
cin >> x;
cout << endl;
cout << "Enter side 2: ";
cin >> y;
cout << endl;
cout << "Enter side 3: ";
cin >> z;
cout << endl;
triangleShape(x, y, z);
return 0;
}
void triangleShape(double x, double y, double z)
{
if (((x+y) z) && ((x+z) y) && ((y+z) x))
{
cout << "You have a triangle!" << endl;
if (x == y && y == z)
cout << "Your triangle is an equilateral" << endl;
else if (x == y || x == z || y == z)
cout << "Your triangle is an isosceles" << endl;
else
cout << "Your triangle is a scalene" << endl;
}
else if ((x+y) <= z || ((x+z) <= y) || ((y+z) <= x))
cout << "You do not have a triangle." << endl;
}