Classroom Example #4 - R 'n R For Reading and Refreshment

  1. In this project, R 'n R Refreshment needs to calculate the amount due for individual orders and maintains accumulated totlas for a summary.  Have a check box for takeout items, which are taxable at 8 percent; all other orders are nontaxable.  Include radio buttons for the five coffee selections: Cappuccino, Espresso, Latte, Iced Cappuccino, and Iced Latte.  The prices for each wil be assigned using these constants:
    Cappuccino = 2.00
    Espresso = 2.25
    Latte = 1.75
    Iced (either) = 2.25

    Use a button for Calculate Selection, which will calculate and display the amount due for each item.  Display appropriate error messages for missing or nonumeric data.

    A button for Clear for Next Item will clear the selections and the amount for the current item and set the focus back to the quantity.  The Clear button should be disabled when the program begins and be enabled after the user begins an order.

    Additional text boxes in a separate group box will display the summary information for the current order, including subtotal, tax and total.

    Buttons at the bottom of the form will be used for New Order, Summary, and Exit.  The New Order button will confirm that the user wants to clear the current order.  If the user agrees, clear the current order and add to the summary totals.  The Summary button should display a message box with the number of orders, the total dollar amount, and the average sale amount per order.

  2. Planning the Form

  3. Planning Objects and Properties

  4. Planning Event Procedures

    Procedure Actions - Pseudocode
    CalculateButton_Click Validate for blank or nonnumeric amount.
      Find price of drink selection
      Multiply price by quantity
      Add amount to subtotal.
      Calculate tax if needed.
      Calculate total = subtotal + tax
      Format and display the values
      Disable the Takeout check box
    Enable the Clear button and New Order button
    ClearButton_Click Clear the coffee selections
    Clear the quantity and the item price.
    Set the focus to the quantity
    NewOrderButton_Click Confirm clearing current order.
    Clear the current order.
    If subtotal > 0
         Accumulate total sales and count
         Set subtotal and total due to 0
    Enable Takeout check box.
    Disable the clear button and the New Order Button
    SummaryButton_Click If current order not added to totals
         Call NewOrderButton_Click
    Calculate the average
    Display the summary totals in a message box
    ExitButton_Click Terminate the project