If I understood it right, you need to put it into a functions that returns a boolean value. So, you can either write the function itself over the main function, or you can write its signature at the top of the main and writing its implementation under the main.
Well, you need to specify the function's return type, in your case is boolean. Than, you need to write its name, the function name, you can use timeCompare. Now you place your function parameters, that I believe that they are both doubles. Finally, you put that code you wrote into de function declaration, and add "return" statements. Something like this:
1 2 3 4 5 6 7 8 9
|
bool timeCompare(double end, double start){
if(end > start){
cout << "Your elapsed time is " << timeDifference(start, end) << " minutes."<<endl;
return true;
} else {
cout <<"Error - End time must be greater than start time." <<endl;
return false;
}
}
|
Ok, than now you just call that function whenever you need it, like that:
And also, expect a boolean value when calling it;
That's it, hope it helps