monito2207

d1_3

Oct 31st, 2021 (edited)
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. /**
  2. *
  3. * Solution to homework assignment 1
  4. * Introduction to programming course
  5. * Faculty of Mathematics and Informatics of Sofia University
  6. * Winter semester 2021/2022
  7. *
  8. * @author Monika Dobrinova
  9. * @idnumber 8MI0600008
  10. * @task 3
  11. * @compiler VC
  12. *
  13. */
  14.  
  15. #include <iostream>
  16. using namespace std;
  17. int main()
  18. {
  19.     int Tabs;
  20.     cin >> Tabs;
  21.     int Salary;
  22.     cin >> Salary;
  23.  
  24.  
  25.     if (Tabs >= 1 && Tabs <= 10 && Salary >= 700 && Salary <= 1500)
  26.     {
  27.         for (int i = 1; i <= Tabs; i++)
  28.         {
  29.             char Site;
  30.             cin >> Site;
  31.             if (Site == 'f')
  32.             {
  33.                 Salary -= 150;
  34.                 if (Salary > 0)
  35.                 {
  36.                     continue;
  37.                 }
  38.                 else
  39.                 {
  40.                     cout << "You have lost your salary." << " ";
  41.                 }
  42.             }
  43.             else if (Site == 'i')
  44.             {
  45.                 Salary -= 100;
  46.                 if (Salary > 0)
  47.                 {
  48.                     continue;
  49.                 }
  50.                 else
  51.                 {
  52.                     cout << "You have lost your salary." << " ";
  53.                 }
  54.             }
  55.             else if (Site == 'r')
  56.             {
  57.                 Salary -= 50;
  58.                 if (Salary > 0)
  59.                 {
  60.                     continue;
  61.                 }
  62.                 else
  63.                 {
  64.                     cout << "You have lost your salary." << " ";
  65.                 }
  66.             }
  67.             else if (Site == 'd')
  68.             {
  69.                 int Same = Salary;
  70.                 Salary = Same;
  71.             }
  72.         }
  73.         if (Salary > 0)
  74.         {
  75.             cout << Salary << " ";
  76.         }
  77.     }
  78.     else
  79.     {
  80.         cout << "-1" << endl;
  81.     }
  82.     return 0;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment