import javax.swing.JFrame; public class Bagel { //----------------------------------------------------------------- // Creates and displays the controls for a bagel shop. //----------------------------------------------------------------- public static void main (String[] args) { JFrame frame = new JFrame ("Bagel Shop"); frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new BagelControls()); frame.pack(); frame.setVisible(true); } }       import java.awt.*; import java.awt.event.*; import javax.swing.*; public class BagelControls extends JPanel { private JComboBox bagelCombo; private JButton calcButton; private JLabel cost; private double bagelCost; public BagelControls() { String[] types = {"Make A Selection...", "Plain", "Asiago Cheese", "Cranberry"}; bagelCombo = new JComboBox(types); calcButton = new JButton("Calc"); cost = new JLabel("Cost = " + bagelCost); setPreferredSize (new Dimension (400, 100)); setBackground(Color.cyan); add(bagelCombo); add(calcButton); add(cost); calcButton.addActionListener (new CalcListener()); } private class CalcListener implements ActionListener { public void actionPerformed (ActionEvent event) { int bagelType = bagelCombo.getSelectedIndex(); switch(bagelType) { case 0: JOptionPane.showMessageDialog(null, "Please select a bagel selection."); break; case 1: bagelCost = 1.00; break; case 2: bagelCost = 2.00; break; case 3: bagelCost = 3.00; break; } cost.setText("Cost = " + bagelCost); } }

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter8: Advanced Data Handling Concepts
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question

BAGEL FILES

 

 

import javax.swing.JFrame;

public class Bagel
{
//-----------------------------------------------------------------
// Creates and displays the controls for a bagel shop.
//-----------------------------------------------------------------
public static void main (String[] args)
{
JFrame frame = new JFrame ("Bagel Shop");
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);

frame.getContentPane().add(new BagelControls());

frame.pack();
frame.setVisible(true);
}
}

 

 

 

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

public class BagelControls extends JPanel
{
private JComboBox bagelCombo;
private JButton calcButton;
private JLabel cost;
private double bagelCost;

public BagelControls()
{
String[] types = {"Make A Selection...", "Plain",
"Asiago Cheese", "Cranberry"};

bagelCombo = new JComboBox(types);

calcButton = new JButton("Calc");

cost = new JLabel("Cost = " + bagelCost);

setPreferredSize (new Dimension (400, 100));
setBackground(Color.cyan);

add(bagelCombo);
add(calcButton);
add(cost);

calcButton.addActionListener (new CalcListener());

}

private class CalcListener implements ActionListener
{
public void actionPerformed (ActionEvent event)
{
int bagelType = bagelCombo.getSelectedIndex();
switch(bagelType)
{
case 0:
JOptionPane.showMessageDialog(null, "Please select a bagel selection.");
break;
case 1:
bagelCost = 1.00;
break;
case 2:
bagelCost = 2.00;
break;
case 3:
bagelCost = 3.00;
break;

}
cost.setText("Cost = " + bagelCost);
}

}
}

3.
Write a program to calculate pay for three different types of employees. The
program will have the following components:
• Combo box to select the type of employee. See Bagel file.
• Two text fields to input the number of hours worked and pay rate.
• A button to calculate the total pay.
• Labels where appropriate.
The types of employees are:
• Salaried: These employees earn $2000 plus a weekly bonus. Use a dialog
box to request the weekly bonus.
• Hourly: Pay = hours times rate.
• Volunteer: These employees do not get paid so their pay will display as 0.
Payroll
Select an Employee Type...
Hours: 0
Rate: 0.0
Calculate Pay
Pay: $0.00
*Name the main driver class Pay and the interface panel class PayPanel.
Transcribed Image Text:3. Write a program to calculate pay for three different types of employees. The program will have the following components: • Combo box to select the type of employee. See Bagel file. • Two text fields to input the number of hours worked and pay rate. • A button to calculate the total pay. • Labels where appropriate. The types of employees are: • Salaried: These employees earn $2000 plus a weekly bonus. Use a dialog box to request the weekly bonus. • Hourly: Pay = hours times rate. • Volunteer: These employees do not get paid so their pay will display as 0. Payroll Select an Employee Type... Hours: 0 Rate: 0.0 Calculate Pay Pay: $0.00 *Name the main driver class Pay and the interface panel class PayPanel.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Linux
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT