int main()
{
int x,y,z;
char answer;
do {
cout << "Type in the first score" << endl;
cin >> x;
cout << "Type in the second score" << endl;
cin >> y;
cout << "Type in the third score" << endl;
cin >> z;
validset (x,y,z);
classify (x,y,z);
cout << "Type c to continue; s to stop";
cin >> answer;
} while (answer == 'c');
return 0;
}
void validset(int x, int y, int z)
{
if (x < 0 || x > 300)
cout << "The group is invalid" << endl;
elseif (y < 0 || y > 300)
cout << "The group is invalid" << endl;
elseif (z < 0 || z > 300)
cout << "The group is invalid" << endl;
else
cout << "The group is valid" << endl;
return ;
}
change validset to return a bool. If the group is invalid, have it return either true or false. Modify your main function to reflect whether it returned true or false, and either do or don't do whatever you want based on this returned value.
bool validset(int x, int y, int z)
{
if (x < 0 || x > 300)
{
cout << "The group is invalid" << endl;
return(false);
}
elseif (y < 0 || y > 300)
{
cout << "The group is invalid" << endl;
return(false);
}
elseif (z < 0 || z > 300)
{
cout << "The group is invalid" << endl;
return(false);
}
else
{
cout << "The group is valid" << endl;
return(true);
}
cout << "This doesn't make sense, error"return(false);
}
in your main() function after line 13:
1 2 3
if (validset(x, y, z) == true)
classify (x,y,z);
else;