Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a programin which the user can order a pizza forpickup. Yourprogram shoul

ID: 653897 • Letter: C

Question

Create a programin which the user can order a pizza forpickup. Yourprogram should have a graphical user interface that contains a combo box for the pizza size(10, 12, 14, or 16 inch). It can contain radio buttons or a combo box for the crust type (hand-tossed, deep-dish, thin crust). You should have check boxes fortoppings (at least five toppings must be offered). The user shouldbe able to enter his her name in a text field. The user will click on a button to process the order or click on a cancel buttonto reset the GUI to the default starting values. You can determine layout, colors, fonts andlook and fed of your GUI. The program should calculate the total price of the pizza and output a confirmation of the order. The output should contain all the information that the user entered for the order including a final price of the order including 5.5%sales tax. The listener for the submit order button should create aninstance of a PizzaOrder object based on the PizzaOrder UML. The Pizza Order constructor will initialize the size, crustType , andname variables. It will also create an instance o f the toppings Array List. Toppings will be added to the ArrayList through the add Topping method. Use the toString() method of Pizza Order to describe the order to be shown in the GUI. Use this method to get the text to output on the GUI in a JTextArea. Prices you will need: 10inchpizza -$10.79 12inchpizza-$12.79 14 inch pizza-$13.79 16inchpizza-$15.79 Toppings cost $1.25 each. Grading: Academic Honesty Guidelines: This is an individual assignment all work must be your own. You may consult the Instructor, SIs,or fellow students for general conceptual help and assistance debugging. They can help you through 1 or 2 bugs, but they should not debug your program for more than 5-10 minutes. You may not copy code from other students (either in electronic copy or "over-the-shoulder" copy) Do not "team-code" this assignment, i.e. it is best to be doing this assignment by yourself or in the lab. You may use your textbook or D2L course content to help with your program. Finally, if you are unsure about any other methodology, PLEASE JUST ASK the Instructor.

Explanation / Answer

//This program allows the user to order a pizza<br />
//<br />
<br />
// Yes, you *will* be editting this file!<br />
//<br />
import java.util.Scanner;<br />
//TASK #5<br />
// You have to add an import statement to use the DecimalFormat class<br />
import java.text.DecimalFormat;<br />
public class PizzaOrder<br />
{<br />
   public static void main (String[] args)<br />
   {<br />
       //TASK #5 Create a DecimalFormat object with 2 decimal places<br />
       // You have to add code!!!<br />
       DecimalFormat DollarFormat = new DecimalFormat();</p>
<p>       //Create a Scanner object to read input<br />
       Scanner keyboard = new Scanner (System.in);</p>
<p>       //Create an instance of a Pizza<br />
       Pizza order = new Pizza ();</p>
<p>       String firstName;           //user's first name<br />
       boolean discount = false;       //flag,<br />
                           //true if user is eligible for discount<br />
       int inches;               //size of the pizza<br />
       char crustType;               //type of crust<br />
       double cost;               //cost of the pizza<br />
       final double TAX_RATE = 5.5%;       //sales tax rate<br />
       double tax;               //amount of tax<br />
       char choice;               //user's choice<br />
       String input;               //user input<br />
       String toppings = "Cheese ";       //list of toppings<br />
       int numberOfToppings = 0;       //number of toppings</p>
<p>       //prompt user and get first name<br />
       System.out.println("Welcome to Mike and Diane's Pizza");<br />
       System.out.print("Enter your first name: ");<br />
       firstName = keyboard.nextLine();</p>
<p>       //determine if user is eligible for discount by<br />
       //having the same first name as one of the owners<br />
       //TASK #1<br />
       // You have to add code!!!<br />
       if (firstName == "Mike" || firstName == "mike")<br />
       {<br />
           discount = true;<br />
       }<br />
       if (firstName == "Diane" || firstName == "diane")<br />
       {<br />
           discount = true;<br />
       }</p>
<p>       //prompt user and get pizza size choice<br />
       System.out.println("Pizza Size (inches ) Cost");<br />
System.out.println(" 10 $10.79");<br />
System.out.println(" 12 $12.79");<br />
System.out.println(" 14 $13.79");<br />
System.out.println(" 16 $15.79");<br />
System.out.println("What size pizza would you like?");<br />
System.out.print("10, 12, 14, or 16 (enter the number only): ");<br />
inches = keyboard.nextInt();</p>
<p>       //set price and size of pizza ordered<br />
       //ADD LINES HERE FOR TASK #2<br />
       // You have to add code!!!<br />
if (inches == 10)<br />
{<br />
    order.setSize(10);<br />
           order.setCost(10.79);<br />
}<br />
       else if (inches == 12)<br />
       {<br />
           order.setSize(12);<br />
           order.setCost(12.79);<br />
       }<br />
       else if (inches == 14)<br />
       {<br />
           order.setSize(14);<br />
           order.setCost(13.79);<br />
       }<br />
       else if (inches == 16)<br />
       {<br />
           order.setSize(16);<br />
           order.setCost(15.79);<br />
       }<br />
       else<br />
       {<br />
           order.setSize(12);<br />
           order.setCost(12.79);<br />
           System.out.println("A size other than the available"<br />
               + " sizes was select, a 12 inche pizza will be made.");<br />
       }</p>
<p>       //consume the remaining newline character<br />
       keyboard.nextLine();</p>
<p>       //prompt user and get crust choice<br />
System.out.println("What type of crust do you want? ");<br />
System.out.println("(H)Hand-tossed, (T) Thin-crust, or "<br />
+ "(D) Deep-dish (enter H, T, or D:): ");<br />
input = keyboard.nextLine();<br />
crustType = input.charAt(0);</p>
<p>       //set user's crust choice on pizza ordered<br />
       //ADD LINES FOR TASK #3<br />
       // You have to add code!!!<br />
       switch (crustType)<br />
       {<br />
           case 'H' :<br />
           case 'h' :<br />
               order.setCrust("Hand-tossed");<br />
               break;<br />
           case 'T' :<br />
           case 't' :<br />
               order.setCrust("Thin-crust");<br />
               break;<br />
           case 'D' :<br />
           case 'd' :<br />
               order.setCrust("Deep-dish");<br />
               break;<br />
           default :<br />
               System.out.println("A choice other than the available choices was made,"<br />
                   + " a hand-tossed pizza will be made.");<br />
               order.setCrust("Hand-tossed");<br />
       }</p>
<p>       //prompt user and get topping choices one at a time<br />
System.out.println("All pizzas come with cheese.");<br />
System.out.println("Additional toppings are $1.25 each,"<br />
+ " choose from");<br />
System.out.println("Pepperoni, Sausage, Onion, Mushroom");</p>
<p>       //if topping is desired,<br />
       //add to topping list and number of toppings<br />
System.out.print("Do you want Pepperoni? (Y/N): ");<br />
input = keyboard.nextLine();<br />
choice = input.charAt(0);<br />
if (choice == 'Y' || choice == 'y')<br />
{<br />
    numberOfToppings += 1;<br />
   toppings = toppings + "Pepperoni ";<br />
}<br />
System.out.print("Do you want Sausage? (Y/N): ");<br />
input = keyboard.nextLine();<br />
choice = input.charAt(0);<br />
if (choice == 'Y' || choice == 'y')<br />
{<br />
   numberOfToppings += 1;<br />
   toppings = toppings + "Sausage ";<br />
}<br />
System.out.print("Do you want Onion? (Y/N): ");<br />
input = keyboard.nextLine();<br />
choice = input.charAt(0);<br />
if (choice == 'Y' || choice == 'y')<br />
{<br />
    numberOfToppings += 1;<br />
toppings = toppings + "Onion ";<br />
}<br />
System.out.print("Do you want Mushroom? (Y/N): ");<br />
input = keyboard.nextLine();<br />
choice = input.charAt(0);<br />
if (choice == 'Y' || choice == 'y')<br />
{<br />
   numberOfToppings += 1;<br />
toppings = toppings + "Mushroom ";<br />
       }</p>
<p>       //set number of toppings and topping list on pizza ordered<br />
       order.setNumToppings(numberOfToppings);<br />
       order.setToppingList(toppings);</p>
<p>       //add additional toppings cost to cost of pizza<br />
       order.setCost(1.25*numberOfToppings);</p>
<p>       //display order confirmation<br />
       System.out.println();<br />
       System.out.println("Your order is as follows: ");<br />
       System.out.println(order.getSize() + " inch pizza");<br />
       System.out.println(order.getCrust() + " crust");<br />
       System.out.println(order.getToppingList());</p>
<p>       //display cost of pizza<br />
       cost = order.getCost();</p>
<p>       //apply discount if user is elibible<br />
       //ADD LINES FOR TASK #4 HERE<br />
       // You have to add code!!!<br />
       if (discount = true)<br />
       {<br />
           System.out.println("You are eligible for a $2.00 discount!!");<br />
           order.setCost(cost - 2);<br />
       }</p>
<p>       //EDIT PROGRAM FOR TASK #5<br />
       //SO ALL MONEY OUTPUT APPEARS WITH 2 DECIMAL PLACES<br />
       System.out.println("The cost of your order is: $" + DollarFormat.format(cost));</p>
<p>       //calculate and display tax and total cost<br />
       tax = cost * TAX_RATE;<br />
       System.out.println("The tax is: $" + DollarFormat.format(tax));<br />
       System.out.println("The total due is: $" + DollarFormat.format(tax+cost));</p>
<p>       System.out.println("Your order will be ready" +<br />
           " for pickup in 30 minutes.");<br />
   }<br />
}<br />

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote