fork download
  1.  
  2. #include <iostream>
  3. using namespace std;
  4. class empolye
  5. {
  6. private:
  7.  
  8. string firstname;
  9. string lastname;
  10. string position ;
  11. int salary;
  12. public:
  13. void set_first(string firstname)
  14. {
  15. this->firstname=firstname;
  16. }
  17. void set_last(string lastname)
  18. {
  19. this->lastname=lastname;
  20. }
  21. void set_pos(string position)
  22. {
  23. this->position=position;
  24. }
  25. void set_salary(int salary)
  26. {
  27. this->salary=salary;
  28. }
  29. string get_first()
  30. {
  31. return firstname;
  32. }
  33. string get_last()
  34. {
  35. return lastname;
  36. }
  37. string get_pos()
  38. {
  39. return position;
  40. }
  41. int get_sal()
  42. {
  43. return salary;
  44. }
  45.  
  46.  
  47. empolye(string firstname,string lastname,string position ,int salary)
  48. {
  49. this->firstname=firstname;
  50. this->lastname=lastname;
  51. this->position=position;
  52. this->salary=salary;
  53. }
  54.  
  55. empolye ()
  56. {
  57. cout<<"default constructor"<<endl;
  58. }
  59. float get_annualsal()
  60. {
  61. return salary*12;
  62. }
  63. float get_raisesal(float percentage)
  64. {
  65. return (salary+((percentage/100)*salary));
  66. }
  67. };
  68.  
  69. int main()
  70. {
  71. string firstname;
  72. string lastname;
  73. string position ;
  74. int salary;
  75. float percentage;
  76. empolye c1( firstname,lastname, position , salary);
  77. cout<<"enter your first name"<<endl;
  78. cin>>firstname;
  79. c1.set_first(firstname);
  80. cout<<"enter your last name"<<endl;
  81. cin>>lastname;
  82. c1.set_last(lastname);
  83. cout<<"enter your position"<<endl;
  84. cin>>position;
  85. c1.set_pos(position);
  86. cout<<"enter your salary"<<endl;
  87. cin>>salary;
  88. c1.set_salary(salary);
  89. cout<<"annual salary is "<<c1.get_annualsal();
  90. cout<<"enter percentage"<<endl;
  91. cin>>percentage;
  92. cout<<"new salary is "<<c1.get_raisesal(percentage);
  93.  
  94. return 0;
  95. }
  96.  
  97.  
  98.  
  99.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
enter your first name
enter your last name
enter your position
enter your salary
annual salary is -2.06236e+09enter percentage
new salary is 1.61771e+09