I have a main which asks the user for hours, minutes, and seconds. As long as the hour is not -99, It is supposed to go through the main, and repeat by asking for a new hours, minutes, and seconds. IF the hours entered is -99 it needs to completely stop and go to the line that says "Later alligator!". I've gone through a few different things trying but I'm not sure. I don't think it was supposed to be very difficult but I must be having a mental block.
int main() {
int hour;
int minute;
int second;
while(hour != -99){
cout << "What is the hour?" << endl;
cin >> hour;
cout << "What is the minute?" << endl;
cin >> minute;
cout << "What is the second?" << endl;
cin >> second;
Clock a(hour, minute, second);
printTimeMessage(a);
a.setHours(hour+2);
a.setMinutes(minute+30);
a.setSeconds(second+15);
cout << "Back to the future!";
printTimeMessage(a);
a.tick();
PrintTimeMessage(a);
a.tick();
PrintTimeMessage(a);
a.tick();
PrintTimeMessage(a);
}
cout << "Later alligator!" << endl;
return 0;
}
Well if I write it like this then it would ask for the hours minutes and seconds each time, and if I put in -99 for hours it still continues to ask for minutes and seconds as well, computes the rest of the main and THEN quits. I need it to quit as soon as -99 is entered.
Nevermind I figured it out. its a while loop like that then an if else statement right below the part where hour is entered saying if(hour == -99) {cout << "later" << endl; }else{ rest of code}