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 for pickup. Your program sho

ID: 653940 • Letter: C

Question

Create a programin which the user can order a pizza for pickup. Your program should have a graphical use rinterface that contains a combo box for the pizza size(10,12,14,or 16inch). It can contain radio buttons or acombo 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 button to reset the GUI to the default starting values. You can determine layout, colors, fonts and look 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 aninstance of a Pizza Order object based on the Pizza Order UML. The Pizza Order constructor will initialize the size, crust Type , and name variables. It will also create an instance o f the toppings Array List Toppings will be a added to the Array Lisi through the add Topping method. Use the to String() method of Pizza Order describe the order to be shown in the GUI. Use this method to get the text to output on the GUI in a JText Area. Prices you will need: 10inchpizza-$10.79 12inchpizza-S12.79 14 inch pizza-$13.79 16inchpizza-$15.79 Toppings cost $1.25 each Academic Honesty Guidelines: This is an individual assignment all work must be your own. Youmay 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. Youmay 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 your selfor in the lab. Youmav 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

import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingUtilities;
class pizzaorder{

int size;
String crustType;
String name
ArrayList<String> Toppings;
public pizzaorder(int size,String crustType,String name){
size=size;
crustType=crustType
name=name;
Toppings= new ArrayList<String>();
}

public void addTopping(String Topping)
{
Toppings.add(String);
}


}
public class MyScrollPane
{

public MyScrollPane()
{
JTextArea test= new JTextArea(5, 30);
test.setLineWrap(true);
test.setWrapStyleWord(true);
test.setEditable(false);

JComboBox cb = new JComboBox(s);
cb.setSelectedIndex(4);
cb.addActionListener(this);
rb1 = new JRadioButton("hand-tossed");

rb2 = new JRadioButton("Deep dish ");
rb2.setSelected(true);

rb3 = new JRadioButton("Thin crust");

// Group the radio buttons
ButtonGroup grp = new ButtonGroup();
grp.add(rb1);
grp.add(rb2);
grp.add(rb3);

// Register a listener for the radio buttons
rb1.addActionListener(this);
rb2.addActionListener(this);
rb3.addActionListener(this);

...cb1 = new JCheckBox(); // Default state is "deselected" (false)
cb1.setText("Toppings 1");

cb2 = new JCheckBox("Toppings 2");

cb3 = new JCheckBox("Toppings 3");

cb4 = new JCheckBox("Toppings 4");
cb5 = new JCheckBox("Toppings 5");


// Register a listener for the checkboxes
cb1.addItemListener(this);
cb2.addItemListener(this);
cb3.addItemListener(this);

JPanel panel = new JPanel();   
panel.add(test);
add(panel);

}
public void itemStateChanged(ItemEvent e) {
Object src = e.getItemSelectable();
if (src == cb1) {
if (e.getStateChange() == ItemEvent.SELECTED)
System.out.println("selected.");
else System.out.println("Checkbox 1 unselected.");
} else if (src == cb2) {
...
} else if (src == cb3) {
...
}
}

public void actionPerformed(ActionEvent e) {
Object src = e.getSource();
if (src == rb1) {
System.out.println("RadioButton 1 selected!");
} else if (src == rb2) {
...
} else if (src == rb3) {
...
}
}
...

public void actionPerformed(ActionEvent e) {
JComboBox cb = (JComboBox) e.getSource();
System.out.println("User chose " + ((String) cb.getSelectedItem()));


private static void createAndShowGUI()
{
JFrame frame = new JFrame();
frame.setSize(800, 250);
frame.setTitle("test1");
frame.setLocation(300, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.getContentPane().add(new MyScrollPane());

frame.setVisible(true);
}

public static void main(String[] args)
{
SwingUtilities.invokeLater(new Runnable() {

@Override
public void run()
{
createAndShowGUI();   
}
});
}

}

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