ENG236 Computer Programming Quiz 4 (5 October 2009) Instruction: open book, closed computer (50 marks) Write a C++ program that shows the following main menu when it starts: === MENU === [Q] Query [A] Add [C] Charge [E] Exit Enter your choice (Q, A, C, or E): The user is expected to enter a character of ‘Q’ , ‘A’ , ‘C’ , ‘E’, ‘q’ , ‘a’ , ‘c’ , or ‘e’ (i.e., case insensitive). When any other characters are entered, the program will display “Unacceptable input, please enter again!” and the main menu will be shown again. If the user enters ‘Q’ or ‘q’, the program will call the function QueryValue(). If the user enters ‘A’ or ‘a’, the program will call the function AddValue(). If the user enters ‘C’ or ‘c’, the program will call the function ChargeValue(). If the user enters ‘E’ or ‘e’, 'the program will call the function Exit(). The function prototypes must be void QueryValue(); void AddValue(float); void ChargeValue(float); void Exit(); * The function QueryValue() will only show a message “Calling function QueryValue().” * The function AddValue() will only show a message “Calling function AddValue().” * The function ChargeValue() will only show a message “Calling function ChargeValue().” * The function Exit() will only show a message “Thank you for using the Octopus!” Whenever the function Exit() has been executed, the program will end (i.e. return to the Command Prompt) after getting back to the main menu. Solution: #include using namespace std; bool menu(); //-| void AddValue(float); // |-- Function prototypes void ChargeValue(float); // | void QueryValue(); // | void Exit(); //-| int main() { bool exitflag =0; while (exitflag == 0) // The loop will stop when meun() returns true exitflag = menu(); return 0; } bool menu() // Function menu() { char choice; cout<<"=== MENU ==="<>choice; switch (choice) { case 'Q': case 'q': QueryValue(); break; case 'A': case 'a': AddValue(0.); break; case 'C': case 'c': ChargeValue(0.); break; case 'E': case 'e': Exit(); return true; default: cout<<"Unacceptable input, please enter again!"<