Guest User

Increase Salary Person

a guest
Jun 18th, 2018
118
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package _002SalaryIncrease;
  2.  
  3. import java.text.DecimalFormat;
  4.  
  5. /**
  6. * Created by IntelliJ IDEA.
  7. * User: LAPD
  8. * Date: 18.6.2018 г.
  9. * Time: 09:09 ч.
  10. */
  11. public class Person {
  12.  
  13. private String firstName;
  14. private String lastName;
  15. private int age;
  16. private double salary;
  17.  
  18. public Person() {
  19. }
  20.  
  21. public Person(String firstName, String lastName,
  22. int age, double salary) {
  23. setFirstName(firstName);
  24. setLastName(lastName);
  25. setAge(age);
  26. setSalary(salary);
  27. }
  28.  
  29. private void setFirstName(String firstName) {
  30. this.firstName = firstName;
  31. }
  32.  
  33. private void setLastName(String lastName) {
  34. this.lastName = lastName;
  35. }
  36.  
  37. private void setAge(int age) {
  38. this.age = age;
  39. }
  40.  
  41. private void setSalary(double salary) {
  42. this.salary = salary;
  43. }
  44.  
  45. public void increaseSalary(Double bonus) {
  46.  
  47. if (this.age < 30) {
  48. bonus /= 2.0;
  49. }
  50.  
  51. this.salary *= 1 + bonus / 100.0;
  52. }
  53.  
  54. @Override
  55. public String toString() {
  56. return String.format("%s %s gets %s leva",
  57. this.firstName,
  58. this.lastName,
  59. new DecimalFormat("#.0#####################################")
  60. .format(this.salary));
  61. }
  62. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×