fork download
  1. /* package whatever; // don't place package name! */
  2. import java.util.*;
  3. import java.lang.*;
  4. import java.io.*;
  5. /* Name of the class has to be "main" only if the class is public. */
  6.  
  7. class Employee
  8. {
  9. private int empID = 1;
  10. private double pay = 1.0;
  11. private int EmpNum;
  12. private double Salary;
  13.  
  14. public Employee(int empID, double pay)
  15. {
  16. EmpNum = empID;
  17. Salary = pay;
  18. }
  19. public Employee(int empID)
  20. {
  21. EmpNum = empID;
  22. Salary = 55;
  23. }
  24. public Employee()
  25. {
  26. EmpNum = 301;
  27. Salary = 55;
  28. }
  29. public void outputInfo()
  30. {
  31. System.out.println("My employee information is: \n" + EmpNum + " Is the Employee ID number and : " + Salary + " Is the pay rate.");
  32. }
  33. }
  34. class Ideone
  35. {
  36. public static void main (String[] args) throws java.lang.Exception
  37. {
  38. Employee myEmployee = new Employee (325, 65);
  39. Employee yourEmployee = new Employee(365);
  40. Employee ourEmployee = new Employee();
  41.  
  42. myEmployee.outputInfo();
  43. yourEmployee.outputInfo();
  44. ourEmployee.outputInfo();
  45. }
  46. }
  47.  
  48.  
Success #stdin #stdout 0.08s 27772KB
stdin
Standard input is empty
stdout
My employee information is:  
325  Is the Employee ID number and :  65.0 Is the pay rate.
My employee information is:  
365  Is the Employee ID number and :  55.0 Is the pay rate.
My employee information is:  
301  Is the Employee ID number and :  55.0 Is the pay rate.