Richard_Sekol

ex3.8

Oct 2nd, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. package ch3;
  2.  
  3. public class testemploy {
  4.  
  5. public static void main(String[] args) {
  6. // TODO Auto-generated method stub
  7. Employee bob = new Employee("Bob", 500.00);
  8. bob.getName();
  9. bob.getSalary();
  10. bob.raiseSalary(20);
  11. bob.getSalary();
  12. }
  13.  
  14. }
  15.  
  16.  
  17. ****************************************************************************************************************************
  18. package ch3;
  19.  
  20. public class Employee {
  21. private String name;
  22. private double moneyPaid;
  23. public Employee(String employeeName, double currentSalary){
  24. name = employeeName;
  25. moneyPaid = currentSalary;
  26. }
  27. public void getName(){
  28. System.out.println(name);
  29. }
  30. public void getSalary(){
  31. System.out.println(moneyPaid);
  32. }
  33. public void raiseSalary(double byPercent){
  34. double percent = byPercent;
  35. double wage = moneyPaid;
  36. moneyPaid = wage * (1 + percent/100);
  37. }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment