Create a programin which the user can order a pizza for pickup. Yourprogram shou
ID: 654207 • Letter: C
Question
Create a programin which the user can order a pizza for pickup. Yourprogram shouldhave a graphical user interface that contains a combo box for the pizza size(10,12,14,or 16inch). It can contain radio buttons or a combo box for the crust type (hand-tossed, deep-dish, thin crust). You should have check boxes for toppings (at least five toppings must be offered). The user should be 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%salestax. The listener for the submit order button should create an instance of a PizzaOrder object based on the PizzaOrder UML. The PizzaOrder constructor will initialize the size, crust Type , and name variables. It will also create an instance o f the toppings ArrayList. Toppings will be added to the ArrayList through the addTppping method. Use the to String() method of PizzaOrder 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. 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 or2 bugs,but they shouldnot debug your program for more than 5-10 miniles. 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. Youmay 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. The listener forthe submit order button should create aninstance of a PizzaQrder object based on the PizzaQrder UML. The PizzaCfrder constructor will initialize the size, crust Iyp^e , andname variables. It will also create an instance o f the toppings AtfayJLisi Toppings will be a dded to the Anayljstthrough the addTppping method. Use the tpJ&j;&gQ; method of PizzaQrdgto describe the order to be shown in the GUI. Use this method to get the text to output on the GUI in a JTextArea. 1. This is an individual assignment all work must be your own. Youmav consult the Instructor, SIs,orfellow students for general conceptual help andassistance debugging. They canhelp vouthrough 1 or2 bugs,but they shouldnot debug your program for more than 5-10 miniles. Youmav not copy code from other students (either in electronic copy or i:over-the-shoulder" copy) Do not i:team-code:: this assignment, i.e. it is best to be doing this assignment by yejarsglf or in the lab. Youmav use your textbook or D2L course contentto help with your program. Finally, if you are unsure about any othermethodology, PLEASE JUST ASK the Instructor.Explanation / Answer
1. import java.util.Scanner;
2. import java.text.DecimalFormat;
3. public class PizzaOrder
4. {
5. public static void main (String [] args)
6. {
7. DecimalFormat formatter = new DecimalFormat (".00");
8. Scanner keyboard = new Scanner (System.in);
9. //Create an instance of a pizza
10. Pizza order = new Pizza ();
11. String firstName; //user's first name
12. boolean discount = false;
13. //is eligible for discount
14. int incheschar crustType;
15. double cost; //cost of the pizza
16. final double TAX_RATE = .08;
17. double tax; //amount of tax
18. char choice;
19. String input; //user input
20. String toppings = "Cheese"; //list of toppings
21. int numberOfToppings = 0; //number of toppings
System.out.println("Welcome to Mike and "+" Diane's Pizza");
22. System.out.prnt("Enter your first name: ");
23. firstName = keyboard.nextLine();
24. input by the user as his/her first name with the first names of the owners,
25. Mike and Diane. Be sure that the comparison is not case sensitive.
26. System.out.println("Pizza Size (inches) Cost");
27. System.out.println(" 10 $10.99");
28. System.out.println(" 12 $12.99");
29. System.out.println(" 14 $14.99");
30. System.out.println(" 16 $16.99");
31. System.out.println("What size pizza would u like?");
32. System.out.print(" 10, 12, 14, or 16" +
33. (enter the number only): ");
34. inches = keyboard.nextInt();
35. statements to
36. execute by the user input size (10, 12, 14, or 16)
38. a 10, 12, 14, 16, and 17 inch pizza.
39. keyboard.nextLine();
40. System.out.println("What type of crust do you want? ");
41. System.out.println("(H)Hand-tossed, (T)Thin-crust, or " + " (D)Deep-dish
42. (enter H, T, or D): ");
43. input = keyboard.nextLine();
44. crustType = input.charSt(0);
45. //prompt user and get topping choices one at a time
46. System.out.println("All pizzas come with cheese. ");
47. System.out.println("Additional toppings are $1.25 each, "+" choose from");
48. System.out.println("Pepperoni, Sausage, Onion, Mushroom");
49. //if topping is desired,
50. System.out.print("Do you want pepperoni? (Y/N): ");
51. input = keyboard.nextLine();
52. choice = input.charAt(0);
53. if (choice == 'Y' || choice == 'y')
54. {
55. numberOfToppings += 1;
56. toppings = toppings + "Pepperoni ";
57. }
58. System.out.print("Do you want Sausage? (Y/N): ");
59. input = keyboard.nextLine();
60. choice = input.charAt(0);
61. if (choice == 'Y' || choice == 'y')
62. {
63. numberofToppings += 1;
64. toppings = toppings + "Onion ";
65.
66. }
67. System.out.print("Do you want Mushroom? (Y/N): ");
68. input = keyboard.nextLine();
69. choice = input.charAt(0);
70. if (choice == 'Y' || choice == 'y')
71. {
72. numberOfToppings += 1;
73. toppings = toppings + "Mushroom ";
74. //set number of toppings and topping list on pizza
75. //ordered
76. order.setNumToppings (numberOfToppings);
77. order.setToppingList(toppings);
78. //add additional toppings cost of pizza
79. order.setCost(1.25 * numberOfToppings);
80. //display order confirmation
81. System.out.println();
82. System.out.println("Your order is as follows: ");
83. System.out.println(order.getSize() + "inch pizza");
84. System.out.println(order.getCrust() + "crust");
85. System.out.println(order.getToppingList());
86. //display cost of pizza
87. cost = order.getCost();
88. ");
89. }
90.
91. //SO ALL MONEY OUTPUT APPEARS WITH 2 DECIMAL PLACES
92. System.out.println("The cost of you order is: $" + cost);
93. //calculate and display tax and total cost
94. tax = cost * TAX_RATE;
95. System.out.println("The tax is: $" + tax);
96. System.out.println("The total due is: $" + (tax + cost));
97. System.out.println("Your order will be ready" + "for pickup in 30 minutes.
98. }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.