cs201 more loopexamples f2007

# cs201 more loopexamples f2007 - Page 1 / Post test loop int...

This preview shows pages 1–2. Sign up to view the full content.

Page 1 // Post test loop int main() { int choice, months; double charges; do {// Display the menu choices cout << "\n\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; { cout << "For how many months? "; cin>> months; while (month < 1) { cout << “Must be a number greater than zero, try again:”; cin>> months; } // Set charges based on user input if (choice == 1) charges = months * 40.0; else if (choice == 2) charges = months * 20.0; else if (choice == 3) charges = months * 30.0; // Display the monthly charges cout << "The total charges are \$" << charges << endl; } else if (choice != 4) { cout << "The valid choices are 1 through 4.\n"; cout << "Run the program again and select one of these.\n"; } } while (choice != 4); return 0; } //======================================================================================== //For Loop

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 04/18/2008 for the course CS 201 taught by Professor Conway during the Fall '07 term at Bowling Green.

### Page1 / 2

cs201 more loopexamples f2007 - Page 1 / Post test loop int...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online