void classify (int,int,int);
bool validset(int,int,int);
int main()
{
int x,y,z;
char answer;
int total = 0;
int vali = 0;
int invali = 0;
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;
if (validset(x, y, z) == true)
classify (x,y,z);
else;
cout << "Type c to continue; s to stop";
cin >> answer;
total++;
vali++;
invali++;
cout << total;
cout << vali;
} while (answer == 'c');
return 0;
}
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);
}
return(false);
}
void classify(int x, int y, int z)
{
cout << "group ran successfully" << endl;
return ;
}
Well, you still have a good amount of work to go but right now the total is equal to the number of times it is ran plus one, every time it runs. This is because in line 27, you have it printing the total, plus one. So every time you run the program (or continue), it prints the total times it was ran, plus one. Aka, the first time it runs, it will be one. Second time will be 3, third time will be 5. Remove the ++ in line 27 to print the correct amount.
in your validset() function, add int& valid, int& invalid. Initialize them to 0, obviously. Every time true is returned, valid++. Every time false is returned, invalid++. Make sure you create these two integers in your main function as well and pass them in the argument.