Please Can some one compile me this as soon as possible tanks
tanksCode://include libraries #include <iostream> using std::cout; using std::cin; using std::endl; #include <string> using std::string; //Global constants const int NUM_MENU_OPTIONS = 5; const int WEEKLY_TEST_MAX = 15; const int ASSIGNMENT1_MAX = 10; const int ASSIGNMENT2_MAX = 15; const int EXAM_MAX = 60; const int NO_MARK = -1; //function prototypes bool getValidMenuChoice( int& ); int getResult( int&, string, int, int ); void showRequiredResult( int, int, int, int ); bool missingResults( int, int, int, int ); void reset( int&, int&, int&, int& ); int getValidInteger( int, int ); int readInteger( void ); void flushStream( void ); int main( void ) { int choice; int weeklyTests, assignment1, assignment2, finalResult; //reset to start reset( weeklyTests, assignment1, assignment2, finalResult ); // now loop until the user choices the exit while ( getValidMenuChoice( choice ) ) { // take the desired action switch ( choice ) { case 1: getResult( weeklyTests, "What did you get for the Weekly Tests", 0, WEEKLY_TEST_MAX ); break; case 2: getResult( assignment1, "What did you get for Assignment 1", 0, ASSIGNMENT1_MAX ); break; case 3: getResult( assignment2, "What did you get for Assignment 2", 0, ASSIGNMENT2_MAX ); break; case 4: getResult( finalResult, "What final result did you want", assignment1+assignment2+weeklyTests, 100-(WEEKLY_TEST_MAX-weeklyTests)- (ASSIGNMENT1_MAX-assignment1)- (ASSIGNMENT2_MAX-assignment2) ); break; case 5: showRequiredResult( weeklyTests, assignment1, assignment2, finalResult ); break; case 6: reset( weeklyTests, assignment1, assignment2, finalResult ); break; } } return 0; } //gets a valid menu option bool getValidMenuChoice( int& choice ) { cout << endl << " * What exam result do I need *" << endl << endl; cout << " 1. Enter Weekly Test result" << endl << " 2. Enter Assignment 1 result" << endl << " 3. Enter Assignment 2 result" << endl << " 4. Enter preferred result" << endl << " 5. Show required exam result " << endl << " 0. Exit the program" << endl << endl; cout << "Enter option => "; choice = getValidInteger ( 0, NUM_MENU_OPTIONS ) ; return choice!=0 ; } // readInteger: Read & validate an integer read from // standard input; // Clear to the end of line & retry if an non-integer is read // Input: none Output: int value read is returned int readInteger() // function definition { int tempInt; // a local variable cin >> tempInt; while (cin.fail()) { cin.clear(); // clear input error flags flushStream(); // clear to end of line cout << "ERROR: You must enter an integer ==> "; cin >> tempInt; // try again } return tempInt; } // flushStream: Clear standard input to EOL void flushStream(void) { char temp = ' '; cin.get(temp); while (temp != '\n') { cin.get(temp); } } // Obtain from user an integer between min and max // Return that integer int getValidInteger ( int min, int max ) { int choice ; choice = readInteger(); // ensure integer within range while ( choice < min || choice > max ) { cout << "Error: please enter a number between " << min << " and " << max << " : " ; choice = readInteger () ; } return choice ; }




Reply With Quote