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

During an earlier in-lecture exercise, you developed a GUI interface like the on

ID: 3692610 • Letter: D

Question

During an earlier in-lecture exercise, you developed a GUI interface like the one below. This assignment will involve modifying that application to include calculating the price of pizzas. Assume that the price of a small pizza is $10.95, the price of a medium pizza is $13.95, and the price of a large pizza is $16.95. The price of each topping (not including plain) is $1.00. Modify the GUI so that it calculates and displays the total price for a pizza. You may choose how and where the price will be displayed.

Explanation / Answer

   */

import java.awt.*;

import java.applet.*;

import javax.swing.*;

public class Pizzaform extends JApplet {

  Container contentPane = getContentPane();

    public void init() {

/Firstly we will create a panel object and after that we will set its layout manager to put the components in a column

        JPanel myPanel = new JPanel();

        myPanel.setLayout(new GridLayout(20, 1, 10, 10));

        myPanel.setBackground(Color.blue);

// now let us create a label for the form heading and add it to the panel

        Label myLabel = new Label("ORDER YOUR PIZZA NOW");

        myPanel.add(myLabel);

// we will now create text fields for the customer's name , address and phonenumber and add them to the panel

        JLabel nameLabel = new JLabel("Name:");

        JTextField myName = new JTextField(30);

        JLabel addressLabel = new JLabel("Address:");

       JTextField myAddress = new JTextField(30);

        JLabel phoneLabel= new JLabel("Phone Number");

        JTextField myPhone = new JTextField(30);

        myPanel.add(nameLabel);

        myPanel.add(myName);

        myPanel.add(addressLabel);

        myPanel.add(myAddress);

        myPanel.add(phoneLabel);

        myPanel.add(myPhone);

     

// Now let is create the radio buttons for pizza size and add them to the panel

        JLabel sizeLabel = new JLabel("Pizza Size");

        ButtonGroup sizeGrouphere = new ButtonGroup();

        JRadioButton p1 = new JRadioButton("small");

        JRadioButton p2 = new JRadioButton("medium");

        JRadioButton p3 = new JRadioButton("large", true);

        JRadioButton p4= new JRadioButton("x-large", true);

// Next we will put the radio buttons in the button group

        sizeGrouphere.add(p1);

        sizeGrouphere.add(p2);

        sizeGrouphere.add(p3);

// Now we will put the radio buttons in the panel

        myPanel.add(sizeLabel);

        myPanel.add(p1);

        myPanel.add(p2);

        myPanel.add(p3);

// This is done to create checkboxes for toppings and adding them to the panel

        JLabel topLabel = new JLabel("Toppings");

        Checkbox z1 = new Checkbox("sausage");

        Checkbox z2 = new Checkbox("pepperoni");

        Checkbox z3 = new Checkbox("onions");

        Checkbox z4 = new Checkbox("tomatoes");

        Checkbox z5 = new Checkbox("olives");

        Checkbox z6 = new Checkbox("mushrooms");

        Checkbox z7 = new Checkbox("green peppers");

        myPanel.add(topLabel);

        myPanel.add(z1);

        myPanel.add(z2);

        myPanel.add(z3);

        myPanel.add(z4);

        myPanel.add(z5);

        myPanel.add(z6);

        myPanel.add(z7);

public void updatePrice()

This is how we will calculate price .

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