Question: This source code has been modified. Further modification is required. Need Help!!!!! import java.awt.*; import java.awt.event.*; import javax.swing.*; //Sammy Student public class SimpleGUI extends JFrame
This source code has been modified. Further modification is required. Need Help!!!!!
import java.awt.*; import java.awt.event.*; import javax.swing.*; //Sammy Student public class SimpleGUI extends JFrame implements ActionListener { private static final long serialVersionUID = 1L; JLabel l1, l2, l3,l4; JButton b1,b2; JTextField t1, t2, t3; JCheckBox check1; SimpleGUI() { l1 = new JLabel(" INPUT 1"); l2 = new JLabel(" INPUT 2"); l3 = new JLabel(" OUTPUT"); l4 = new JLabel(" "); check1 = new JCheckBox("click to select"); b1 = new JButton("BUTTON 1"); b2 = new JButton("EXIT"); t1 = new JTextField(10); t2 = new JTextField(10); t3 = new JTextField(10); check1.setSelected(true); add(l1); add(t1); add(l2); add(t2); add(l3); add(t3); add(check1); add(l4); add(b1); add(b2);
b1.addActionListener(this); b2.addActionListener(this); setSize(500,300); setLayout(new GridLayout(5,2)); setTitle("Simple Java GUI"); } public void actionPerformed(ActionEvent ae) { float a, b, c; if (check1.isSelected()){ if(ae.getSource() == b1) { a = Float.parseFloat(t1.getText()); b = Float.parseFloat(t2.getText()); c = a + b; t3.setText(String.valueOf(c)); } } else{ System.out.println("Please check the checkbox"); } if(ae.getSource() == b2){ System.exit(0); } } public static void main(String args[]) { SimpleGUI a = new SimpleGUI(); a.setVisible(true); a.setLocation(200, 200);
} }
Alter the Program
Now change the GUI application such that the screen will appear as follows:
PROJECT Simple Java GUI: Salary Calculator
Then alter your program code such that when a current salary and percent rate are entered into their respective text fields a new salary is then computed, with a bonus amount added to the new salary when the checkbox is selected.
You can test your program with these two sample data scenarios:
Scenario I ( bonus pay NOT included )
Current Salary $ 30,000
Percent Rate 5 %
Bonus Pay NO
New Salary $ 31,500
Scenario II ( bonus pay included )
Current Salary $ 30,000
Percent Rate 5 %
Bonus Pay YES ( $ 500 )
New Salary $ 32,000
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
