Saleh127

java assnmnt1

Jun 19th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. package mns;
  2. import java.util.Scanner;
  3. public class Employee {
  4. private String firstName;
  5. private String lastName;
  6. private double monthlySalary;
  7. public Employee() {
  8. firstName = null;
  9. lastName = null;
  10. monthlySalary = 0.0;
  11. }
  12. public String getfirstName() {
  13. return firstName;
  14. }
  15. public String getlastName() {
  16. return lastName;
  17. }
  18. public double getSalary() {
  19. return monthlySalary;
  20. }
  21. public void setfirstName(String first) {
  22. firstName = first;
  23. }
  24. public void setlastName(String last) {
  25. lastName = last;
  26. }
  27. public void setSalary(double salary) {
  28. monthlySalary = salary;
  29. }
  30. public static void main(String args[]) {
  31. Employee em1 = new Employee();
  32. Employee em2 = new Employee();
  33. Scanner inp = new Scanner(System.in);
  34. String first;
  35. String last;
  36. double salary;
  37. System.out.println("Enter First Name of 1st Employee: ");
  38. first = inp.next();
  39. em1.setfirstName(first);
  40. System.out.println("Enter Last Name of 1st Employee: ");
  41. last = inp.next();
  42. em1.setlastName(last);
  43. System.out.println("Enter Monthly Salary of 1st Employee: ");
  44. salary = inp.nextDouble();
  45. em1.setSalary(salary);
  46. System.out.println("Enter First Name of 2nd Employee: ");
  47. first = inp.next();
  48. em2.setfirstName(first);
  49. System.out.println("Enter Last Name of 2nd Employee: ");
  50. last = inp.next();
  51. em2.setlastName(last);
  52. System.out.println("Enter Monthly Salary of 2nd Employee: ");
  53. salary = inp.nextDouble();
  54. em2.setSalary(salary);
  55. System.out.println("1st Employee's Full Name and Yearly Salary.\n");
  56. System.out.println(em1.getfirstName() + " " + em1.getlastName() + " " + em1.getSalary() * 12 + "\n");
  57. System.out.println("2nd Employee's Full Name and Yearly Salary.\n");
  58. System.out.println(em2.getfirstName() + " " + em2.getlastName() + " " + em2.getSalary() * 12 + "\n");
  59. System.out.println("New Annual Salary After 10% Raise\n");
  60. System.out.println(em1.getfirstName() + " " + em1.getlastName() + " " + (em1.getSalary() * 1.10 * 12 + "\n"));
  61. System.out.println(em2.getfirstName() + " " + em2.getlastName() + " " + (em2.getSalary() * 1.10 * 12 + "\n"));
  62. }
Advertisement
Add Comment
Please, Sign In to add comment