Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. package lab9exercise4;
  2.  
  3. import java.util.Scanner;
  4.  
  5. /**
  6. *
  7. * @author huanmingan
  8. */
  9. public class Lab9exercise4 {
  10.  
  11. /**
  12. * @param args the command line arguments
  13. */
  14. public static void main(String[] args) {
  15. Scanner scan = new Scanner(System.in);
  16. System.out.print("\n\tEnter the employee's name: ");
  17. String aName = scan.nextLine();
  18. Employee theEmployee = new Employee(aName);
  19.  
  20. char selection = 'a';
  21. while (selection != 'q')
  22. {
  23. if (theEmployee.salary() != 0 )
  24. {
  25. System.out.println();
  26. System.out.println("\tType: ");
  27. System.out.println("\t\tp - to promote the employee");
  28. System.out.println("\t\td - to demote the employee");
  29. System.out.println("\t\tr - to raise the employee's salary by a given amount");
  30. System.out.println("\t\tv - to view the employee's details");
  31. System.out.println("\t\tq - to quit");
  32. System.out.println("\t\tf - to fire the employee\n");
  33. System.out.print("\tEnter selection: ");
  34. selection = scan.next().charAt(0);
  35.  
  36. switch (selection)
  37. {
  38. case 'p':
  39. theEmployee.promote();
  40. break;
  41. case 'd':
  42. theEmployee.demote();
  43. break;
  44. case 'r':
  45. System.out.print("\tEnter amount of rise: ");
  46. int rise = scan.nextInt();
  47. theEmployee.raiseSalaryBy(rise);
  48. break;
  49. case 'v':
  50. System.out.println("\t" + theEmployee.toString());
  51. break;
  52. case 'f':
  53. theEmployee.fire();
  54. break;
  55. }
  56. }
  57. else
  58. {
  59. System.out.println();
  60. System.out.println("\t\tThe employee has been fired, \n\tType: ");
  61. System.out.println("\t\th - to hire the employee ");
  62. System.out.println("\t\tv - to view the employee's details");
  63. System.out.println("\t\tq - to quit");
  64. System.out.print("\n\tEnter selection: ");
  65. selection = scan.next().charAt(0);
  66. switch (selection)
  67. {
  68. case 'h':
  69. {
  70. System.out.print("Enter a starting salary for the employee: ");
  71. int startingsalary = scan.nextInt();
  72. theEmployee.startingsalary(startingsalary);
  73. break;
  74. }
  75. case 'v':
  76. System.out.println("\t" + theEmployee.toString());
  77. break;
  78. }
  79. }
  80. }
  81. System.out.println("\tPROGRAM ENDED\n");
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement