// John Doe // while loop demo #4 // day of week?? #include #include using namespace std; // ******************* constant declaration statements ******* const double BOOK_PRICE = 9.00; // price per book int main() { // *************** variable declaration statements ******* int numBooks = 0; // # of books for this order int totalNumBooks = 0; // total # of books ordered by customer double bookSubtotal = 0.0; // subtotal cost of books bool userWantsToExit = false; // flag variable to exit while loop int menuChoice = 0; // customer's menu choice while (!userWantsToExit) { cout << "1 books" << endl; cout << "2 movies" << endl; cout << "3 peanuts" << endl; cout << "4 checkout" << endl; cout << "Enter your choice: "; cin >> menuChoice; if (menuChoice == 1) { cout << "Enter number of books: "; cin >> numBooks; if (numBooks >= 0 && numBooks <= 10) { totalNumBooks += numBooks; } else { cout << "Invalid input." << endl; } } else if (menuChoice == 2) { // movie inputs & calculations here } else if (menuChoice == 3) { // peanuts inputs & calculations here } else if (menuChoice == 4) { userWantsToExit = true; } else { cout << "Invalid input." << endl; } bookSubtotal = totalNumBooks * BOOK_PRICE; } // *************** output display ************************ cout << "You owe $" << bookSubtotal << endl; system("pause"); return 0; }// end of main