Get the answers you need at Westonci.ca, where our expert community is always ready to help with accurate information. Get precise and detailed answers to your questions from a knowledgeable community of experts on our Q&A platform. Our platform provides a seamless experience for finding reliable answers from a network of experienced professionals.
Sagot :
The generated test cases for the function assuming another developer coded the function is given below in a C++ program.
THE CODE
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
// define the data type "triangletype" with {values}
enum triangleType { scalene, isosceles, equilateral, noTriangle };
// Prototype function which returns the position of triangleType{value}
// Example: Scalene = 0, isosceles = 1, etc. These are zero indexed.
triangleType triangleShape(double a, double b, double c);
// Prototype function which takes the integer value of the
// triangle type and outputs the name of triangle
string shapeAnswer(int value);
int main() {
double inputA;
double inputB;
double inputC;
cout << "To determine whether a triangle is either:" << endl;
cout << setw(50) << " - Scalene" << endl; // Unequal in length
cout << setw(52) << " - Isosceles" << endl; // Two sides equal length
cout << setw(54) << " - Equilateral" << endl; // All sides equal
cout << setw(57) << " - Not a triangle" << endl;
cout << "Enter side A: ";
cin >> inputA;
cout << "Enter side B: ";
cin >> inputB;
cout << "Enter side C: ";
cin >> inputC;
cout << "The triangle is " << shapeAnswer(triangleShape(inputA, inputB, inputC)) << endl;
}
triangleType triangleShape(double a, double b, double c) {
triangleType answer;
if ( c >= (a + b) || b >= (a + c) || a >= (b + c) ) {
answer = noTriangle;
}
else if (a == b && b == c) {
answer = equilateral;
}
// Test the 3 options for Isosceles equality
else if ( (a == b) && (a != c) || (b == c) && (b != a) || (a == c) && (a != b) ) {
answer = isosceles;
}
else {
answer = scalene;
}
return answer;
}
string shapeAnswer(int value) {
string answer;
switch (value) {
case 0:
answer = "Scalene";
break;
case 1:
answer = "Isosceles";
break;
case 2:
answer = "Equilateral";
break;
case 3:
answer = "Not a triangle";
break;
default:
break;
}
return answer;
}
Read more about C++ programs here:
https://brainly.com/question/20339175
#SPJ1
We hope this was helpful. Please come back whenever you need more information or answers to your queries. Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. Discover more at Westonci.ca. Return for the latest expert answers and updates on various topics.