Advertisement
Guest User

Employee v.2

a guest
Jul 26th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. package com.example.at2;
  2. import java.util.Scanner;
  3.  
  4.  
  5. public class Employee {
  6. private String name;
  7. private int empNo;
  8. private double salary;
  9. private String EmployerName;
  10. private int zipCode;
  11. private String title;
  12. public int age;
  13. public static void main(String[] args) {
  14. // TODO Auto-generated method stub
  15. determineTitle();
  16.  
  17. // name, empNo = constant
  18. // rest can change
  19.  
  20. Employee john = new Employee("john", 12345);
  21.  
  22. }
  23.  
  24. public void setAge(int age){
  25. this.age = age;
  26. }
  27. public int getAge(){ return age;}
  28. public int getEmpNo(){ return empNo;}
  29. public void printAge(int age){
  30. System.out.println(age);
  31. }
  32. public double getSalary() {
  33. return salary;
  34. }
  35.  
  36. public void setSalary(double salary) {
  37. this.salary = salary;
  38. }
  39.  
  40. public int getZipCode() {
  41. return zipCode;
  42. }
  43.  
  44. public void setZipCode(int zipCode) {
  45. this.zipCode = zipCode;
  46. }
  47.  
  48. public String getTitle() {
  49. return title;
  50. }
  51.  
  52. public void setTitle(String title) {
  53. this.title = title;
  54. }
  55.  
  56. public void printEmpNo(int empNo){
  57. System.out.println(empNo);
  58. }
  59. //read in
  60. public static void determineTitle(){
  61. Scanner sc = new Scanner(System.in);
  62. System.out.println("Please input years of experience: ");
  63. int i = sc.nextInt();
  64.  
  65. if(i == 0){
  66. System.out.println("Trainee");
  67. } else if((i == 1) || (i == 2)){
  68. System.out.println("Manager");
  69. } else {
  70. System.out.println("Senior Manager");
  71. }
  72. }
  73. public Employee(){
  74.  
  75. }
  76. public Employee(String name, int empNo){
  77. this.name = name;
  78. this.empNo = empNo;
  79. }
  80.  
  81. }
  82.  
  83.  
  84.  
  85. /*
  86. Input: 1
  87. Output: Manager
  88.  
  89. Input: 0
  90. Output: Trainee
  91.  
  92. Input: 5
  93. Output: Senior Manager
  94. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement