For my assignment I have to take sets of 3 integers separated by spaces from the user input and determine whether or not they can form a triangle, and if so whether or not it's a right triangle. The user presses enter between each set of 3 integers. When the user is done entering sets, they'll enter the set "0 0 0" and the program will output the count of right triangle sets, non right triangle sets, and non triangular sets. The constrictions are as follows:
"the following libraries will not be accepted:
#include <bits/stdc++.h> //nonstandard
#include <sstream> //beyond chapter nine
#include <array> //beyond chapter nine
#include <stdlib.h> //a C library, not C++"
I am trying to test 3 values entered by the user using a while loop and the && operator. However the loop is exiting if only one condition is met. How can I make it so that all 3 conditions need to be met for the loop to exit?
Here is my loop, I can't figure out the code format on here ._.:
cout << "Type here: ";
cin >> x >> y >> z;
while (x != 0 && y != 0 && z != 0) {
result = getRightTriangleType(x, y, z);
switch (result) {
case rightTriangular:
rightTriangleCount = rightTriangleCount++;
cout << "Type here: ";
cin >> x >> y >> z;
continue;
case nonRightTriangular:
nonRightTriangleCount = nonRightTriangleCount++;
cout << "Type here: ";
cin >> x >> y >> z;
continue;
default:
nonRightTriangleCount = nonRightTriangleCount++;
cout << "Type here: ";
cin >> x >> y >> z;
continue;
}
}
https://walmartone.me/