I'm supposed to use Enumeration (Switch Statements) to determine from the user input three values which type of triangle is used. A Isoceles , Scalene, Equilateral, and last but not least values that don't correspond to a triangle.
I'm just very confused with the entire topic and the tutorials don't seem to help.
Would appreciate any references or actual in code uses of something similar so I can get a grasp on it.
This is what ive gotten so far but im really confused on the entire usage of enumeration and/or switch statements.
Any help would be greatly appreciated.
Code:
#include<iostream>
#include<fstream>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
void screenHeader();
void getValues(int &sOne, int &sTwo, int &sThree);
void sendInput(int &sOne, int &sTwo, int &sThree);
enum triangle {ISOSCELES, EQUILATERAL, SCALENE, NO_TRIANGLE}sOne, sTwo, sThree;
float answer2 = 0 ;
int main()
{
int sOne, sTwo, sThree;
int another = 1;
char answer;
system("clear");
screenHeader();
while(another != 0) {
getValues(sOne, sTwo, sThree);
enum triangle {ISOSCELES, EQUILATERAL, SCALENE, NO_TRIANGLE}sOne, sTwo, sThree;
cout << " " << endl;
cout << "Would you like to continue (Y or N)? " ;
cin >> answer;
if(answer != 'y' && answer != 'Y')
{
answer2++;
another = 0 ;
}
if(answer != 'y' && answer != 'Y')
{
cout << "Number of sets of input analyzed: " << answer2 << endl;
cout << "PROGRAM TRIANGLE has terminated." << endl;
}
}
return 0;
}
void screenHeader()
{
cout << "Program TRIANGLE " << endl;
cout << "-------------------------------------------------------------------------------------------" << endl;
cout << "This program will request that you enter integar values for three sides of a triangle. " << endl;
cout << "The program will analyze the values that you enter and determine if the values constitute " << endl;
cout << "an isoceles trianle, an equilateral triangle, a scalene triangle, or that no triangle can " << endl;
cout << "be formed with the values entered. " << endl;
cout << "-------------------------------------------------------------------------------------------" << endl;
}
void getValues(int &sOne, int &sTwo, int &sThree)
{
cout << " " << endl;
cout << "Please enter a value for side 1 of your triangle: " ;
cin >> sOne;
cout << "Please enter a value for side 2 of your triangle: " ;
cin >> sTwo;
cout << "Please enter a value for side 3 of your triangle: " ;
cin >> sThree;
sendInput(sOne, sTwo, sThree);
}
void sendInput(int &sOne, int &sTwo, int &sThree)
{
cout << " " << endl;
cout << "The lengths of the sides that you entered were: " << sOne << ", " << sTwo << ", and " << sThree << "." << endl;
}