__________________________(400, 200);
Blog
import java.awt.event.________________;
import java.awt.event.________________;
private JTextField ______________, totalCostField;
private JTextField ______________, totalCostField;
The following Swing program creates a simple coffee shop cas…
The following Swing program creates a simple coffee shop cash register system. It allows users to select different types of coffee (Espresso, Latte, Cappuccino) from a dropdown menu, input the quantity they want to purchase, and calculate the total cost. The program displays the total cost in a non-editable text field. It includes action listeners to handle the calculation of the total cost based on the selected coffee type and quantity. The prices for each coffee type are predefined within the program. The GUI for the cash register looks like the following: Please fill in the blanks for questions 1 – 10 (Type your answer in the box provided below each question). import javax.swing.*; import java.awt.*; import java.awt.event.________________; // fill in the blank Line 1 import java.awt.event.ActionListener; // public class CoffeeShopCashRegister extends JFrame { // private JComboBox coffeeComboBox; private JTextField ______________, totalCostField; // fill in the blank Line 2 private JButton calculateButton; // public CoffeeShopCashRegister() { setTitle(“Coffee Shop Cash Register”); __________________________(400, 200); // fill in the blank Line 3 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(_________________________); // fill in the blank Line 4 // Coffee selection JLabel coffeeLabel = new JLabel(“Select Coffee:”); coffeeComboBox = new JComboBox(new String[]{“Espresso”, “Latte”, “Cappuccino”}); add(coffeeLabel); add(________________________); // fill in the blank Line 5 // Quantity input JLabel quantityLabel = new JLabel(“Quantity:”); quantityField = new JTextField(); add(quantityLabel); add(quantityField); // Total cost display JLabel totalCostLabel = new JLabel(“Total Cost:”); totalCostField = new JTextField(); totalCostField.__________________(false); // fill in the blank Line 6 add(totalCostLabel); add(totalCostField); // Calculate button calculateButton = new JButton(“Calculate”); calculateButton.addActionListener(new CalculateButtonListener()); add(new JLabel()); // Empty label for spacing add(_____________________); // fill in the blank Line 7 } private class CalculateButtonListener implements ActionListener { @Override public void actionPerformed(ActionEvent e) { String selectedCoffee = (String) coffeeComboBox.getSelectedItem(); int quantity = Integer.parseInt(__________________);// fill in the blank Line 8 double price = 0.0; switch (selectedCoffee) { case “Espresso”: price = 2.50; break; case “Latte”: price = 3.50; break; case “Cappuccino”: price = 4.00; break; } double totalCost = price * quantity; totalCostField.setText(String.format(“$%.2f”, __________________));// fill in the blank Line 9 } } public static void main(String[] args) { CoffeeShopCashRegister frame = new CoffeeShopCashRegister(); frame.setVisible(_________________); // fill in the blank Line 10 } }
For the given multiplexer circuit, what will appear at the o…
For the given multiplexer circuit, what will appear at the output bank for the given control line selectors;
The output of a full subtractor is same as —————–…
The output of a full subtractor is same as ————————
Represent the number (-13)10 as a binary number using 2’s co…
Represent the number (-13)10 as a binary number using 2’s complement:
Quantity supplied is _____________ (positively/negatively) a…
Quantity supplied is _____________ (positively/negatively) associated with price increases, although the degree to which quantity supplied can respond to price changes depends on the elasticity of supply.
When making a capital budgeting investment decision, most fi…
When making a capital budgeting investment decision, most firms prefer the Internal Rate of Return (IRR) over Net Present Value (NPV).
Ratios are meaningful for any business, whether as a relativ…
Ratios are meaningful for any business, whether as a relative or isolated benchmark. Industry comparison are irrelevant.