Advertisement
Garey

Test

Oct 17th, 2017
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.33 KB | None | 0 0
  1. #include<iostream>
  2. #include<locale.h>
  3. using namespace std;
  4.  
  5.     const int Week_Work_Hours = 40;
  6.     const double Salary_Per_Hour = 10.0;
  7.  
  8. struct Worker
  9. {
  10.     char name[32];
  11.     int hours_per_week;
  12.     double salary;
  13. };
  14. void calculate_salary(Worker worker1)
  15. {
  16.     if(worker1.hours_per_week <= Week_Work_Hours)
  17.     {
  18.         worker1.salary=(worker1.hours_per_week*Salary_Per_Hour)-((worker1.hours_per_week*Salary_Per_Hour)*(20/100));
  19.         cout<<"Çàïëàòàòà íà "<<worker1.name<<" ñ "<<worker1.hours_per_week<<" ðàáîòíè ÷àñà å:"<<worker1.salary<<"ëâ."<<endl;
  20.     }
  21.     else if(worker1.hours_per_week > Week_Work_Hours && worker1.hours_per_week <= Week_Work_Hours+3)
  22.     {
  23.         worker1.salary=(worker1.hours_per_week*Salary_Per_Hour)+((worker1.hours_per_week*Salary_Per_Hour)*(5/100));
  24.         cout<<"Çàïëàòàòà íà "<<worker1.name<<" ñ "<<worker1.hours_per_week<<" ðàáîòíè ÷àñà å:"<<worker1.salary<<"ëâ."<<endl;
  25.     }
  26.     else if(worker1.hours_per_week <= Week_Work_Hours+5)
  27.     {
  28.         worker1.salary=(worker1.hours_per_week*Salary_Per_Hour)+((worker1.hours_per_week*Salary_Per_Hour)*(8/100));
  29.         cout<<"Çàïëàòàòà íà "<<worker1.name<<" ñ "<<worker1.hours_per_week<<" ðàáîòíè ÷àñà å:"<<worker1.salary<<"ëâ."<<endl;
  30.     }
  31.     else if(worker1.hours_per_week <= Week_Work_Hours+10)
  32.     {
  33.         worker1.salary=(worker1.hours_per_week*Salary_Per_Hour)+((worker1.hours_per_week*Salary_Per_Hour)*(7/100));
  34.         cout<<"Çàïëàòàòà íà "<<worker1.name<<" ñ "<<worker1.hours_per_week<<" ðàáîòíè ÷àñà å:"<<worker1.salary<<"ëâ."<<endl;
  35.     }
  36.     else// if(worker1.hours_per_week > Week_Work_Hours+10)
  37.     {
  38.         worker1.salary=(worker1.hours_per_week*Salary_Per_Hour)+((worker1.hours_per_week*Salary_Per_Hour)*(6/100));
  39.         cout<<"Çàïëàòàòà íà "<<worker1.name<<" ñ "<<worker1.hours_per_week<<" ðàáîòíè ÷àñà å:"<<worker1.salary<<"ëâ."<<endl;
  40.     }
  41. }
  42. int main()
  43. {
  44.  
  45.     setlocale(LC_ALL, "Bulgarian");
  46.     Worker worker1[5];
  47.     unsigned int n;
  48.     cout<<"Âúâåäè îò 3 äî 5 ðàáîòíèêà:"<<endl;
  49.     cin>>n;
  50.     for(int i=0;i<n;i++)
  51.     {
  52.         cout<<"Âúâåäè èìå íà ðàáîòíèê:"<<endl;
  53.         cin>>worker1[i].name;
  54.         cout<<"Âúâåäè áðîé ðàáîòåíè ÷àñîâå ñåäìè÷íî:"<<endl;
  55.         cin>>worker1[i].hours_per_week;
  56.     }
  57.     for(int i=0;i<n;i++)
  58.     {
  59.         calculate_salary(worker1[i]);
  60.  
  61.     }
  62.     return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement