Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This source code has been modified. Further modification is required. Need Help!

ID: 3817076 • Letter: T

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

Explanation / Answer

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,t4;
JCheckBox check1;

SimpleGUI()
{
l1 = new JLabel(" Current Salary");
l2 = new JLabel(" Percent Rate");
l3 = new JLabel(" Bonus");
l4 = new JLabel("New Salary");
check1 = new JCheckBox("click to select");
b1 = new JButton("New Salary");
b2 = new JButton("EXIT");
t1 = new JTextField(10);// Current salary entered
t2 = new JTextField(10); //Percent rate entered
t3 = new JTextField(10); //Bonus pay entered
t4=new JTextField(10); //New Salary displayed
check1.setSelected(true);
  
add(l1);
add(t1);
add(l2);
add(t2);
add(l3);
add(t3);
add(l4);
add(t4);
add(check1);

//Buttons Added
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,d;
if (check1.isSelected()){
if(ae.getSource() == b1)
{
a = Float.parseFloat(t1.getText());
b = Float.parseFloat(t2.getText());
c = Float.parseFloat(t3.getText());
d = a + b*a/100+c;
t4.setText(String.valueOf(d));// Set current salary in Text field
}
}
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);
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote