Question

Develop an application using a JTabbedPane to order a pizza. You will need to ask the...

Develop an application using a JTabbedPane to order a pizza. You will need to ask the customer for their name and phone number. You will ask for the size (choose one) and toppings (choose many) and compute the total. After computing the total, provide a button to display the order summary, which includes the name, phone number, size, toppings, and total. The prices are listed below. Screenshots of a possible solution are included. Your application must include four tabs and open a new window when the button is clicked.Small: 8.00Medium: 10.00Large: 12.00Each topping is 2.00 extra.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

// File: JTabbedPaneTest.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class OrderSummary extends JFrame
{
JTextArea jtaSummary;

OrderSummary(String summary, String title)
{
  super(title);
  setLayout(new BorderLayout());
  jtaSummary = new JTextArea(summary);
  add(jtaSummary);
}
}

public class JTabbedPaneTest extends JFrame implements ActionListener
{
JTabbedPane jtp = new JTabbedPane();

JLabel jlblWelcome = new JLabel("Welcome to Java Pizza");
JLabel jlblName = new JLabel("Name: ");
JLabel jlblPhone = new JLabel("Phone number: ");
JLabel jlblSize = new JLabel("What size pizza?");
JLabel jlblToppings = new JLabel("What toppings would you like?");
JLabel jlblDue = new JLabel("Total Due");

JTextField jtfName = new JTextField(20);
JTextField jtfPhone = new JTextField(20);
JTextField jtfTotalDue = new JTextField(20);

JRadioButton jrbSmall = new JRadioButton("Small");
JRadioButton jrbMedium = new JRadioButton("Medium");
JRadioButton jrbLarge = new JRadioButton("Large");

JButton jbtnSummary = new JButton("Order Summary");

JCheckBox pepper = new JCheckBox("Pepperoni");
JCheckBox sause = new JCheckBox("Sausage");
JCheckBox mushroom = new JCheckBox("Mushroom");
JCheckBox onion = new JCheckBox("Onion");

ButtonGroup groupsize = new ButtonGroup();

JPanel customer = new JPanel();
JPanel size = new JPanel();
JPanel toppings = new JPanel();
JPanel total = new JPanel();

String rdsize = "";

public JTabbedPaneTest(String title)
{
  super(title);  
  
  customer.add(jlblWelcome);
  customer.add(jlblName);
  customer.add(jtfName);
  customer.add(jlblPhone);
  customer.add(jtfPhone);
  
  groupsize.add(jrbSmall);
  groupsize.add(jrbMedium);
  groupsize.add(jrbLarge);
  
  size.add(jlblSize);
  size.add(jrbSmall);
  size.add(jrbMedium);
  size.add(jrbLarge);  
  
  toppings.add(jlblToppings);
  toppings.add(pepper);
  toppings.add(sause);
  toppings.add(mushroom);
  toppings.add(onion);  
  
  total.add(jlblDue);
  total.add(jtfTotalDue);
  total.add(jbtnSummary);  
  
  jtp.add("Customer", customer);
  jtp.add("Size", size);
  jtp.add("Toppings", toppings);
  jtp.add("Total", total);
  
  add(jtp);
  
  jbtnSummary.addActionListener(this);
}

public void actionPerformed(ActionEvent ae)
{
  double finalAmount = 0;  
  String finalSize = "";
  String finalToppings = "";
  
  if(jrbSmall.isSelected())
  {
   finalSize = "Small";
   finalAmount = 8.0;
  }
  else if(jrbMedium.isSelected())
  {
   finalSize = "Medium";
   finalAmount = 10.0;
  }
  else if(jrbLarge.isSelected())
  {
   finalSize = "Large";
   finalAmount = 12.0;
  }


  if(pepper.isSelected())
  {
   finalToppings = "Pepperoni";
   finalAmount += 2.0;
  }
  if(sause.isSelected())
  {
   finalToppings = "Sausage";
   finalAmount += 2.0;
  }
  if(mushroom.isSelected())
  {
   finalToppings = "Mushroom";
   finalAmount += 2.0;
  }
  if(onion.isSelected())
  {
   finalToppings = "Onion";
   finalAmount += 2.0;
  }
  
  jtfTotalDue.setText("" + finalAmount);
  
  String result = "";
  result += "Customer Name : " + jtfName.getText() + "\n";
  result += "Phone number : " + jtfPhone.getText() + "\n";
  result += "Size : " + finalSize + "\n";
  result += "Toppings : " + finalToppings + "\n";
  result += "Total : " + finalAmount + "\n";
  
  OrderSummary order = new OrderSummary(result, "Order Summary");
  order.setSize(new Dimension(300, 300));
  order.setVisible(true);
}

public static void main(String args[])
{
  JTabbedPaneTest jtpTest = new JTabbedPaneTest("Java Pizza");
  jtpTest.setSize(new Dimension(300, 200));
  jtpTest.setVisible(true);
}
}

------------------------------------------------------------

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Develop an application using a JTabbedPane to order a pizza. You will need to ask the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Complete the following ERD for this pizza order application: The application you are hired to develop...

    Complete the following ERD for this pizza order application: The application you are hired to develop the database for must keep track of the orders for custom pizzas by customers. When customers register, they include their name and address in the registration form. A customer can order multiple different custom pizzas in a single order. Each pizza in an order has a quantity and size (Small, Medium, Large or Extra Large). Each pizza has a cheese option and crust option,...

  • Create an order entry screen program in C# to give a total for an individual pizza...

    Create an order entry screen program in C# to give a total for an individual pizza order. The Pizza order should have radio buttons for small $7, medium $9, and large $12 choices for the pizza. There should be a checkbox for drink (where a drink is $2 added if it is checked and nothing added if it is not checked. Include a textbox for the customer’s name. Have a button to calculate the subtotal (pizza choice and whether there...

  • Hello, please help me to answer my assignment, i highly appreciate your effort, kindly explain it...

    Hello, please help me to answer my assignment, i highly appreciate your effort, kindly explain it clearly. Kindly put your codes in (NOTEPAD). Thank you very much. Write a VB application that will facilitate a pizza order. 1.The user interface should have a form containing all components pertaining to pizza order presented in either option buttons or check boxes. 2.Controls must also be grouped in frames according to size, toppings, or crust type. 3.The summary of order must be presented...

  • Create a user friendly interface to order a pizza. Use appropriate controls (radio buttons, list boxes,...

    Create a user friendly interface to order a pizza. Use appropriate controls (radio buttons, list boxes, check boxes) to obtain the type of pizza (e.g. small, medium, large) and the toppings. Calculate the cost of the pizza based upon the size, number of toppings and delivery charge. Display a summary of the order in a text area along with the total cost. Provide buttons which places the order and clears the order. Allow for multiple pizzas to orders Submit as...

  • Please create the following pizza order form. My form images are not needed but I can...

    Please create the following pizza order form. My form images are not needed but I can supply them for you. Please be creative with your form. Pizza Order FormCalculate Order Total Clear Order When the Calculate Order Total button has been clicked, do the following: Verify that the Customer Name and Phone Number are not blank. Display an appropriate message if either textbox is empty and place the cursor in the appropriate textbox. Verify that at least one Pizza Choice...

  • Pizza Hub sells pizzas of four sizes, S, M, L, X. The prices are $6.99, $8.99,...

    Pizza Hub sells pizzas of four sizes, S, M, L, X. The prices are $6.99, $8.99, $12.50, and $15.00 respectively. For each pizza, there is an optional extra topping that costs $1.00, $2.00, $3.25, and $4.50 for each size. Write a program to prompt a user to order one pizza of any size, and then ask if an extra topping is needed. Based on these, calculate and display the cost of the ordered pizza accordingly. For this program, you need...

  • C# Programming Exercise and Bonus Exercise (Next Page) 1) Define a class called OrderPizza that has...

    C# Programming Exercise and Bonus Exercise (Next Page) 1) Define a class called OrderPizza that has member variables to track the type of pizza being order (either deep dish, hand tossed, or pan) along with the size (small, medium or large), type of toppings (pepperoni, cheese etc.) and the number of toppings. Create accessors for each property (ex.: type, size, type of toppings, and number of toppings). Implementation class should have a CalculateOrderPayment method to compute the total cost of...

  • Q1. rewrite the exercise on April 4 by adding the following operations: 1) In the php...

    Q1. rewrite the exercise on April 4 by adding the following operations: 1) In the php script, create an associative array named $order that stores the following values: - the number of cheese toppings; - the number of pepperoni toppings; - the number of ham toppings; - the size of the ordered pizza; - the number of the ordered pizza; - the total cost of the order; - the discount rate; - the total cost after the discount. 2) the...

  • A fitness tracking app company has asked you to develop a windows application using a GUI...

    A fitness tracking app company has asked you to develop a windows application using a GUI to determine the total amount of hours somebody has exercised during their lifetime, assuming on average a user has exercises 2.5 hours per week. When the user uses the app, they will enter the following: First Name: Last Name: Date of Birth (in mm/dd/yyyy): Current Date (in mm/dd/yyyy) This program should display the users name and the number of hours the user has exercised...

  • Your task for this project is to write a parser for a customer form. You need to develop a Java a...

       Your task for this project is to write a parser for a customer form. You need to develop a Java application using Parboiled library. Your program should include a grammar for the parser and display the parse tree with no errors. Remember that your fifth and sixth assignments are very similar to this project and you can benefit from them. The customer form should include the following structure: First name, middle name (optional), last name Street address, city, state (or...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT