fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. class Employee
  4. {
  5. private:
  6. string name;
  7. int id;
  8. double salary;
  9. public :
  10. void set_info(string A,int B,double C)
  11. {
  12. name=A;
  13. id=B;
  14. salary=C;
  15.  
  16. }
  17. void new_salary(double r)
  18. {
  19. if(r>=2.5&&r<=5)
  20. {
  21. salary=salary+(salary*(r/10));
  22. }
  23. else
  24. {
  25. cout<<"Invalid performance rating.Salary remain unchanged"<<endl;
  26. }
  27. }
  28.  
  29. string get_name()
  30. {
  31. return name;
  32. }
  33. int get_id()
  34. {
  35. return id;
  36. }
  37. double get_salary()
  38. {
  39. return salary;
  40. }
  41.  
  42. /* void displayInfo() {
  43.   cout << "\n--- Employee Details ---" << endl;
  44.   cout << "Name : " << name << endl;
  45.   cout << "Employee ID : " << employeeID << endl;
  46.   cout << "Salary : " << salary << endl;
  47.   } */
  48.  
  49. };
  50.  
  51. int main()
  52. {
  53. string X;
  54. int Y;
  55. double Z;
  56. double r;
  57. cout<<"INPUT:"<<endl;
  58. // cin.ignore();
  59. cout<<"Enter employee name:";
  60.  
  61. getline(cin,X);
  62. cout<<"Enter employee id:";
  63. cin>>Y;
  64. cout<<"Enter current Salary:";
  65. cin>>Z;
  66. Employee E1;
  67. E1.set_info(X,Y,Z);
  68. cout<<"Enter performance rating(2.5-5.0):";
  69. cin>>r;
  70. E1.new_salary(r);
  71.  
  72. cout<<endl<<"OUTLINE:"<<endl;
  73. cout<<"Name :"<<E1.get_name()<<endl;
  74. cout<<"Employee ID:"<<E1.get_id()<<endl;
  75. cout<<"Salary :"<<E1.get_salary()<<endl;
  76.  
  77.  
  78. return 0;
  79. }
  80.  
  81.  
  82.  
  83.  
Success #stdin #stdout 0.01s 5304KB
stdin
Standard input is empty
stdout
INPUT:
Enter employee name:Enter employee id:Enter current Salary:Enter performance rating(2.5-5.0):Invalid performance rating.Salary remain unchanged

OUTLINE:
Name    :
Employee ID:5388
Salary  :1.14345e-310