Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove

Instructions

The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly.

DebugFourteen2.java

// Displays list of payment options // - credit card, check or cash // Displays fee for using each - 5%, 2% or 0%

import javax.swing.*; import java.awt.*; import java.awt.event.*;

public class DebugFourteen2 extends JFrame implements ItemListener { FlowLayout flow = new FlowLayout(); JComboBox payMethod = new JComboBox(); JLabel payList = new JLabel("Pay List"); JTextField totFees = new JTextField(25); String pctMsg = new String("per cent will be added to your bill"); int[] fees = {5, 2, 0}; int feePct = 0; String output; int fee = 0; public DebugFourteen2() { super("Pay List) setDefaultClosetOperation(JFrame.EXIT_ON_CLOSE); setLayout(flowlayout); payMethod.addItemListener(this); add(payList); add(payMethod); payMethod.addItems("Credit card"); payMethod.addItems("Check"); payMethod.addItems("Cash"); add(totFees); } public static void main(String[] arguments) { JFrame cframe = new DebugFourteen2(); cframe.setSize(350,150); cframe.setVisible(true); } @Override public void itemStateChanged(ItemEvent list) { Object source = list.getSource(); if(source == payMethod) { int fee = payMethod.getSelectedIndex(); feePct = fees[fee]; output = feePct + " " + pctMsg; totFees.setTheText(output) } } }

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

DebugFourteen3.java

// User selects pizza topping and sees price import javax.swing.*; import java.awt.*; import java.awt.event.*; public class DebugFourteen3 extends JFrame implements ItemListener { FlowLayout flow = new FlowLayout(); JComboBox pizzaBox = new JComboBox(); JLabel toppingList = new JLabel("Topping List); JLabel aLabel = new JLabel("Paulos's American Pie"); JTextField totPrice = new JTextField(10); int[] pizzaPrice = {7, 10, 10, 8, 8, 8, 8}; int totalPrice = 0; String output; int pizzaNum; public DebugFourteen3() { super("Pizza List"); setDefaultCloseOperation(JFrame.EXITONCLOSE); setLayout(flow); pizzaBox.addItemListener(); add(toppingList); pizzaBox.addItem("cheese"); pizzaBox.addItem("sausage"); pizzaBox.addItem("pepperoni"); pizzaBox.addItem("onion"); pizzaBox.addItem("green pepper"); pizzaBox.addItem("green olive"); pizzaBox.addItem("black olive"); add(pizzaBox); add(aLabel); add(totPrice); } public static void main(String[] arguments) { JFrame frame = new DebugFourteen3(); frame.setSizeValues(200, 150); frame.setVisible(true); }

@Override public void itemStateChanged(ItemEvent list) { Object source = list.getSource(); if(source == pizzaBox) { int pizzaNum = pizzaBox.getSelectedIndex(); total = pizzaPrice[pizzaNum]; output = "Pizza Price $" + totPrice; totPrice.setTextValue(output); } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 2 Lncs 13427

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124251, 978-3031124259

More Books

Students also viewed these Databases questions

Question

What is the purpose of a mission statement?

Answered: 1 week ago

Question

2. How will the team select a leader?

Answered: 1 week ago