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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education