QuestionQuestion

Transcribed TextTranscribed Text

Assignment #2 Yoshi’s Pizza Orders Problem Description You have been asked to develop a program for Yoshi’s Pizza restaurant. The program will calculate and display the cost of a customer’s order including GST and deposit (where applicable). Each customer may order any number of each type of food and beverage (pizza, side, or cola). The restaurant needs to track and display the total revenue for the day, the total of each type of sale (pizza, side, or cola), and the total number of customers for the day. The cost of each type of food and beverage item is as follows:  Pizza - Small: $12.75  Pizza - Large: $18.75  Sides - Salad: $7.25  Cola – Can (355 mL): $1.75  Cola – 6-pack (6 x 355 mL): $8.00  Cola – 2L $3.75 The deposit for each size of cola is as follows:  Small bottle deposit (<=750 mL) $0.10  Large bottle deposit (>=1000 mL) $0.25 The restaurant name and today’s date (the date when the program is executed) must be displayed at the top of the output. At the end of program, you will display a concluding statement (see sample program output for details). Hint: use Date and SimpleDateFormat to create a formatted presentation of today’s date Sample Program Output The following is a sample run that can be used to verify your totals for each customer and the daily sales for the store; user input is shown as bold underline. ******************************************* *** Welcome to Yoshi's Pizza Restaurant *** *** Today's date is Jan-31-2020 *** ******************************************* ------------------------------ Item Size Price ------------------------------ Pizza Small $12.75 Pizza Large $18.75 Sides Salad $7.25 Cola 1 can $1.75 Cola 6-pack $8.00 Cola 2 L $3.75 ------------------------------ Enter item choice (P - Pizza, S - Sides, C - Cola, or X - exit): p Enter size of pizza (s or l): s Enter number of small pizzas to order: 2 Pizza cost is (incl. GST): $26.78 Assignment #2 Yoshi’s Pizza Orders Is customer order complete? (Y/N) N ------------------------------ Item Size Price ------------------------------ Pizza Small $12.75 Pizza Large $18.75 Sides Salad $7.25 Cola 1 can $1.75 Cola 6-pack $8.00 Cola 2 L $3.75 ------------------------------ Enter item choice (P - Pizza, S - Sides, C - Cola, or X - exit): p Enter size of pizza (s or l): l Enter number of large pizzas to order: 3 Pizza cost is (incl. GST): $59.06 Is customer order complete? (Y/N) Y The total cost for this customer is $85.84 ------------------------------ Item Size Price ------------------------------ Pizza Small $12.75 Pizza Large $18.75 Sides Salad $7.25 Cola 1 can $1.75 Cola 6-pack $8.00 Cola 2 L $3.75 ------------------------------ Enter item choice (P - Pizza, S - Sides, C - Cola, or X - exit): s Enter number of salads to order: 3 Side cost is (incl. GST): $22.84 Is customer order complete? (Y/N) y The total cost for this customer is $22.84 ------------------------------ Item Size Price ------------------------------ Pizza Small $12.75 Pizza Large $18.75 Sides Salad $7.25 Cola 1 can $1.75 Cola 6-pack $8.00 Cola 2 L $3.75 ------------------------------ Enter item choice (P - Pizza, S - Sides, C - Cola, or X - exit): c Enter size of cola (one, six, or two): one Enter number of single colas to order: 6 Cola cost is (incl. GST and deposit): $11.66 Is customer order complete? (Y/N) n ------------------------------ Item Size Price ------------------------------ Pizza Small $12.75 Pizza Large $18.75 Sides Salad $7.25 Cola 1 can $1.75 Cola 6-pack $8.00 Cola 2 L $3.75 ------------------------------ Assignment #2 Yoshi’s Pizza Orders Enter item choice (P - Pizza, S - Sides, C - Cola, or X - exit): c Enter size of cola (one, six, or two): six Enter number of cola 6-packs to order: 1 Cola cost is (incl. GST and deposit): $9.03 Is customer order complete? (Y/N) n ------------------------------ Item Size Price ------------------------------ Pizza Small $12.75 Pizza Large $18.75 Sides Salad $7.25 Cola 1 can $1.75 Cola 6-pack $8.00 Cola 2 L $3.75 ------------------------------ Enter item choice (P - Pizza, S - Sides, C - Cola, or X - exit): c Enter size of cola (one, six, or two): two Enter number of 2L colas to order: 1 Cola cost is (incl. GST and deposit): $4.20 Is customer order complete? (Y/N) y The total cost for this customer is $24.88 ------------------------------ Item Size Price ------------------------------ Pizza Small $12.75 Pizza Large $18.75 Sides Salad $7.25 Cola 1 can $1.75 Cola 6-pack $8.00 Cola 2 L $3.75 ------------------------------ Enter item choice (P - Pizza, S - Sides, C - Cola, or X - exit): x Daily Summary -------------------------------------------- Item Size Price Qty. Sold -------------------------------------------- Pizza Small $12.75 2 Pizza Large $18.75 3 Sides Salad $7.25 3 Cola 1 can $1.75 6 Cola 6-pack $8.00 1 Cola 2 L $3.75 1 -------------------------------------------- The total revenue for the day is $133.56 The total number of customers today is 3 Good bye! Additional Program Requirements 1. Declare and use constants for the each of the costs of the different items being sold (e.g. COST_PIZZA_SM=12.75, COST_PIZZA_LG=18.75, etc.), GST and deposit prices. (No magic numbers!) 2. Use a character data type for the type of purchase being made, i.e. the type value will be one of p, P, s, S, d or D. Assignment #2 Yoshi’s Pizza Orders 3. Use a switch to respond appropriately to the type of purchase being made (pizza, side or drinks) 4. Use if statements within certain switch cases for additional required branching.  Within the if statements, use an appropriate data type for the purchase being made, for example if the customer is buying a small pizza, then you can use the value ‘s’. 5. You need to check if the customer’s order is complete or if you are still calculating the current customer’s order (see sample program output). 6. Your program will continue until the order details for the final customer of the day have been calculated. Use a sentinel-controlled loop – stopping when the user enters “x” or “X” (for Exit). 7. All cost values must be printed out to only two decimal places. 8. It is NOT necessary to use the “rounded cents” technique for your cost calculations. 9. You are NOT expected to check for invalid input values. Cost Calculation Rules  Use the following rules when computing your cost calculations:  6-pack of cola incurs a deposit cost of $0.10 per can in the case, i.e. a 6-pack has an added deposit cost of $0.60.  Add deposit charges before calculating GST

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.util.Scanner;

/**
*
* @author
*/
public class YoshiPizza {

    /**
    * global constant variables
    */
    private static final double COST_PIZZA_SM = 12.75;
    private static final double COST_PIZZA_LA = 18.75;
    private static final double COST_SALAD_SIDES = 7.25;
    private static final double COST_CAN_COLA = 1.75;
    private static final double COST_PACKS_COLA = 8.00;
    private static final double COST_2L_COLA = 3.75;

    //private static final int
    private static final String[] ITEMS = {
       "Pizza", "Pizza", "Sides", "Cola", "Cola", "Cola"
    };
    private static final String[] SIZES = {
       "Small", "Larges", "Salad", "1 can", "6-pack", "2 L"
    };
    private static final double[] PRICES = {
       COST_PIZZA_SM, COST_PIZZA_LA, COST_SALAD_SIDES,
       COST_CAN_COLA, COST_PACKS_COLA, COST_2L_COLA
    };

    public static void main(String[] args) {

       /**
         * constant variables
         *
         * Declare and use constants for the each of the costs of the different
         * items being sold (e.g. COST_PIZZA_SM=12.75, COST_PIZZA_LG=18.75,
         * etc.), GST and deposit prices. (No magic numbers!)
         */
       final double COST_DEPOSIT_SM = 0.1;
       final double COST_DEPOSIT_PACK = COST_DEPOSIT_SM * 6;
       final double COST_DEPOSIT_LG = 0.25;
       final double GST = 1.05;
       final char YES = 'y';
       final char PIZZA = 'p';
       final char COLA = 'c';
       final char SIDES = 's';
       final String ONE = "one";
       final String TWO = "two";
       final String SIX = "six";
       final char SMALL = 's';
       final char LARGE = 'l';
       final char EXIT = 'x';

       /**
         * variables
         */
       Scanner scanner = new Scanner(System.in);
       double total = 0;
       char selection;
       double cost;
       double subtotal;
       int number;
       int numPizzaSM = 0;
       int numPizzaLA = 0;
       int numSide = 0;
       int numColaOne = 0;
       int numColaTwo = 0;
       int numColaSix = 0;
       int numCustomer = 0;

       System.out.println(
                "******************************************* \n"
                + "*** Welcome to Yoshi's Pizza Restaurant *** \n"
                + "***    Today's date is Jan-31-2020    *** \n"
                + "*******************************************");

       do {
            // payemnt of the current customer
            subtotal = 0;
            // loop until the custaomer want to stop
            do {
                // show menuw
                printMenu();
                System.out.print("Enter item choice (P - Pizza, "
                        + "S - Sides, C - Cola, or X - exit): ");
                // get selection

                // Use a character data type for the type of purchase
                // being made, i.e. the type value will be
                // one of p, P, s, S, d or D.
                selection = scanner.next().toLowerCase().charAt(0);
                // the customer want to stop
                if (selection == EXIT) {
                   // Use a sentinel-controlled loop – stopping when
                   // the user enters “x” or “X” (for Exit).
                   // Your program will continue until the order details
                   // for the final customer of the day have
                   // been calculated.
                   break;
                }...

By purchasing this solution you'll be able to access the following files:
YoshiPizza.java.

$21.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats