// This program displays a menu and asks the user to make a // selection. A switch statement determines which item // the user has chosen. #include #include using namespace std; int main() { int choice; // Menu choice int months; // Number of months double charges; // Monthly charges // Constants for membership rates const double ADULT = 40.0; const double SENIOR = 30.0; const double CHILD = 20.0; // Display the menu and get a choice. cout << "\t\tHealth Club Membership Menu\n\n"; cout << "1. Standard Adult Membership\n"; cout << "2. Child Membership\n"; cout << "3. Senior Citizen Membership\n"; cout << "4. Quit the Program\n\n"; cout << "Enter your choice: "; cin >> choice; // Validate and process the menu choice. if (choice >= 1 && choice <= 3) { // Get the number of months. cout << "For how many months? "; cin >> months; // Set the numeric output formatting. cout << fixed << showpoint << setprecision(2); // Respond to the user's menu selection. switch (choice) { case 1: charges = months * ADULT; break; case 2: charges = months * CHILD; break; case 3: charges = months * SENIOR; } // Display the monthly charges. cout << "The total charges are $"; cout << charges << endl; } else if (choice != 4) { cout << "The valid choices are 1 through 4. Run the\n"; cout << "program again and select one of those.\n"; } return 0; }