Question: Homework #2 Create a GUI front end for Homework #1. See details below. 1. Create a GUI that has two check boxes which allow a

Homework #2

Create a GUI front end for Homework #1. See details below.

1. Create a GUI that has two check boxes which allow a user to select between an employee and a manager. (20 points)

2. Create a GUI that pops up ONLY if the employee box is selected. This new window should contain JLabels with JTextFields that allow the user to enter in all the employee's relevant information - e.g. Name, Title, Age, and Salary. Use the same inputs from the Jane Doe case in Homework #1. The new window should also allow the user to raise the employee's salary by a certain percentage - JTextField (% Increase). Use the employee raiseSalary(int percent) method from Homework #1. Lastly, the new window should include a calculate button which computes and outputs the new salary when pressed. In this case, the new salary would be 82125.0. (20 points)

3. Create a GUI that pops up ONLY if the manager box is selected. This new window should contain JLabels with JTextFields that allow the user to enter in all the manager's relevant information - e.g. Name, Title, Age, Years of Experience, Highest Degree Earned, Salary, and Promotion Bonus. Use the same inputs from the John Doe case in Homework #1. The new window should also allow the user to raise the manager's salary by a certain percentage - JTextField (% Increase). Use the manager raiseSalary(int percent) method from Homework #1. Lastly, the new window should include a calculate button which computes and outputs the new salary when pressed. In this case, the new salary would be 114500.0. (20 points)

4. Create a GUI error message that pops up if the user enters invalid information into the GUI from question #2. (20 points)

5. Create a GUI error message that pops up if the user enters invalid information into the GUI from question #3. (20 points)

Develop a report that contains an overview of the source code. It should also include print screens of the GUIs from each scenario mentioned above. Copy source code and paste in the report's Appendix similar to what was provided in the Homework #1 assignment. Note, all responses should be contained in ONE WORD or PDF document. Other formats will not be accepted.

homework #1 is given below

Homework #1

Please refer to the code in the Appendix (pages 2 - 6) to answer the following questions

. 1. What is the relationship between the Employee class and the Manager class? What concept does this demonstrate? (10 points)

2. What would happen if mySalary were declared private instead of protected? (15 points)

3. Write the output for each section of print statements. (15 points)

4. Which raiseSalary() method does m.raiseSalary(10) execute? Why? What concept does this demonstrate? (20 points)

5. Which raiseSalary() method does e1.raiseSalary(10) execute? Why? What concept does this demonstrate? (20 points)

6. Which raiseSalary() method does e2.raiseSalary(10,1) execute? Why? What concept does this demonstrate? (20 points)

APPENDIX

Traits.java

public interface Traits

{

public String getName();

public String getTitle();

}

Employee.java

public class Employee implements Traits

{

private String myName;

private String myTitle;

protected double mySalary;

private int myAge;

public Employee(String name, String title, double salary, int age)

{

myName = name;

myTitle = title;

mySalary = salary;

myAge = age;

}

public String getName()

{

return myName;

}

public String getTitle()

{

return myTitle;

}

public double getSalary()

{

return mySalary;

}

public int getAge()

{

return myAge;

}

public void raiseSalary(int percent)

{

mySalary = mySalary + 0.95 * percent * 0.01 * mySalary;

}

public void raiseSalary(int percent, int cost_of_living_adjustment)

{

mySalary = mySalary + 0.95 * percent * 0.01 * mySalary + cost_of_living_adjustment * 0.01 * mySalary;

}

}

Manager.java

public class Manager extends Employee

{

private int yearsWorked;

private String highestDegree;

private double promotionBonus;

public Manager(String name, String title, double salary, int age, int experience, String degree, double bonus)

{

super(name, title, salary, age);

yearsWorked = experience;

highestDegree = degree;

promotionBonus = bonus;

}

public int getExperience()

{

return yearsWorked;

}

public String getDegree()

{

return highestDegree;

}

public double getBonus()

{

return promotionBonus;

}

public void raiseSalary(int percent)

{

mySalary = mySalary + 0.95 * percent * 0.01 * mySalary + promotionBonus;

}

}

Test.java

public class Test

{

public static void main(String args[])

{

Manager m = new Manager("John Doe", "Department Head", 100000.0, 54, 31, "PhD", 5000.0);

Employee e1 = new Employee("Jane Doe", "Resource Analyst", 75000.0, 41);

Employee e2 = new Employee("Jim Doe", "Engineer", 85000.0, 45);

System.out.println("Name : " + m.getName());

System.out.println("Title : " + m.getTitle());

System.out.println("Age : " + m.getAge());

System.out.println("Years of Experience : " + m.getExperience());

System.out.println("Highest Degree Earned : " + m.getDegree());

System.out.println("Salary : " + m.getSalary());

System.out.println("Promotion Bonus : " + m.getBonus());

m.raiseSalary(10);

System.out.println("Salary Raised!");

System.out.println("New Salary : " + m.getSalary());

System.out.println(" ");

System.out.println("Name : " + e1.getName());

System.out.println("Title : " + e1.getTitle());

System.out.println("Age : " + e1.getAge());

System.out.println("Salary : " + e1.getSalary());

e1.raiseSalary(10);

System.out.println("Salary Raised");

System.out.println("New Salary : " + e1.getSalary());

System.out.println(" ");

System.out.println("Name : " + e2.getName());

System.out.println("Title : " + e2.getTitle());

System.out.println("Age : " + e2.getAge());

System.out.println("Salary : " + e2.getSalary());

e2.raiseSalary(10,1);

System.out.println("Salary Raised");

System.out.println("New Salary : " + e2.getSalary());

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!