Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lab9exercise4;
- import java.util.Scanner;
- /**
- *
- * @author huanmingan
- */
- public class Lab9exercise4 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- System.out.print("\n\tEnter the employee's name: ");
- String aName = scan.nextLine();
- Employee theEmployee = new Employee(aName);
- char selection = 'a';
- while (selection != 'q')
- {
- if (theEmployee.salary() != 0 )
- {
- System.out.println();
- System.out.println("\tType: ");
- System.out.println("\t\tp - to promote the employee");
- System.out.println("\t\td - to demote the employee");
- System.out.println("\t\tr - to raise the employee's salary by a given amount");
- System.out.println("\t\tv - to view the employee's details");
- System.out.println("\t\tq - to quit");
- System.out.println("\t\tf - to fire the employee\n");
- System.out.print("\tEnter selection: ");
- selection = scan.next().charAt(0);
- switch (selection)
- {
- case 'p':
- theEmployee.promote();
- break;
- case 'd':
- theEmployee.demote();
- break;
- case 'r':
- System.out.print("\tEnter amount of rise: ");
- int rise = scan.nextInt();
- theEmployee.raiseSalaryBy(rise);
- break;
- case 'v':
- System.out.println("\t" + theEmployee.toString());
- break;
- case 'f':
- theEmployee.fire();
- break;
- }
- }
- else
- {
- System.out.println();
- System.out.println("\t\tThe employee has been fired, \n\tType: ");
- System.out.println("\t\th - to hire the employee ");
- System.out.println("\t\tv - to view the employee's details");
- System.out.println("\t\tq - to quit");
- System.out.print("\n\tEnter selection: ");
- selection = scan.next().charAt(0);
- switch (selection)
- {
- case 'h':
- {
- System.out.print("Enter a starting salary for the employee: ");
- int startingsalary = scan.nextInt();
- theEmployee.startingsalary(startingsalary);
- break;
- }
- case 'v':
- System.out.println("\t" + theEmployee.toString());
- break;
- }
- }
- }
- System.out.println("\tPROGRAM ENDED\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement