GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

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 } }

Read Details

Molecule A below is a potential lead compound.  Which of the…

Molecule A below is a potential lead compound.  Which of the following structures represent A as it predominantly exists at pH 7               

Read Details

Select the correct Shannon expansion for the given logical f…

Select the correct Shannon expansion for the given logical function 

Read Details

Find the result of (1100)2 – (0011)2 using 2’s complement.

Find the result of (1100)2 – (0011)2 using 2’s complement.

Read Details

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. 

Read Details

How should a firm undertake an analysis of its ratios?

How should a firm undertake an analysis of its ratios?

Read Details

What are the two common types of debt: [type1] and [type2]?

What are the two common types of debt: [type1] and [type2]?

Read Details

How can firms limit competition or entry into the market? 

How can firms limit competition or entry into the market? 

Read Details

If a determinant of demand or supply changes, then the entir…

If a determinant of demand or supply changes, then the entire price-quantity relationship changes. 

Read Details

What type of analysis compares the firm to itself over time?…

What type of analysis compares the firm to itself over time? 

Read Details

Posts pagination

Newer posts 1 … 44,130 44,131 44,132 44,133 44,134 … 94,399 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top