// File: superbowl.cxx // Written by Michael Main (Sep 1, 2005) // This is a first example of a program with a loop // that has an if-statement inside. #include using namespace std; int main( ) { int bears = 0; // The Bears' score int colts = 0; // The Colts' score int quarter = 1; // Which quarter are we in? int input; // Number entered by user while ((quarter <= 4) || (bears == colts)) { cout << "Enter Bears points in quarter " << quarter << ": "; cin >> input; if (input >= 0) bears = bears + input; else cout << "Illegal input" << endl; cout << "Enter Dasterdly Colts points in quarter " << quarter << ": "; cin >> input; if (input >= 0) colts = colts + input; else cout << "Illegal input" << endl; quarter++; } if (bears > colts) cout << "The Bears win!" << endl; else cout << "The Colts win!" << endl; return EXIT_SUCCESS; }