avr39ripe

cppBestManagerFrom3

Jun 28th, 2021
645
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     enum sales{ RangeA = 500, RangeB = 1000};
  6.     enum percents {A = 3, B = 5, C = 8};
  7.  
  8.     const int salary{ 200 };
  9.     const int bonus{ 200 };
  10.  
  11.     int percent{ 0 };
  12.  
  13.     int manager1{ 0 };
  14.     int manager2{ 0 };
  15.     int manager3{ 0 };
  16.  
  17.     int salary1{ salary };
  18.     int salary2{ salary };
  19.     int salary3{ salary };
  20.  
  21.     bool best1{ false };
  22.     bool best2{ false };
  23.     bool best3{ false };
  24.  
  25.     std::cout << "Enter Manager #1 sales\n";
  26.     std::cin >> manager1;
  27.  
  28.     std::cout << "Enter Manager #2 sales\n";
  29.     std::cin >> manager2;
  30.  
  31.     std::cout << "Enter Manager #3 sales\n";
  32.     std::cin >> manager3;
  33.  
  34.     // Manager #1
  35.  
  36.     if (manager1 < sales::RangeA)
  37.     {
  38.         percent = percents::A;
  39.     }
  40.     else if (manager1 >= sales::RangeA and manager1 < sales::RangeB)
  41.     {
  42.         percent = percents::B;
  43.     }
  44.     else
  45.     {
  46.         percent = percents::C;
  47.     }
  48.  
  49.     salary1 += manager1 * (percent / (float)100);
  50.  
  51.  
  52.     // Manager #2
  53.  
  54.     if (manager2 < sales::RangeA)
  55.     {
  56.         percent = percents::A;
  57.     }
  58.     else if (manager2 >= sales::RangeA and manager2 < sales::RangeB)
  59.     {
  60.         percent = percents::B;
  61.     }
  62.     else
  63.     {
  64.         percent = percents::C;
  65.     }
  66.  
  67.     salary2 += manager2 * (percent / (float)100);
  68.  
  69.     // Manager #3
  70.  
  71.     if (manager3 < sales::RangeA)
  72.     {
  73.         percent = percents::A;
  74.     }
  75.     else if (manager3 >= sales::RangeA and manager3 < sales::RangeB)
  76.     {
  77.         percent = percents::B;
  78.     }
  79.     else
  80.     {
  81.         percent = percents::C;
  82.     }
  83.  
  84.     salary3 += manager3 * (percent / (float)100);
  85.  
  86.     best1 = salary1 > salary2 and salary1 > salary3;
  87.     best2 = salary2 > salary1 and salary2 > salary3;
  88.     best3 = salary3 > salary1 and salary3 > salary2;
  89.  
  90.     if (best1)
  91.     {
  92.         salary1 += bonus;
  93.     }
  94.     else if (best2)
  95.     {
  96.         salary2 += bonus;
  97.     }
  98.     else
  99.     {
  100.         salary3 += bonus;
  101.     }
  102.  
  103.     std::cout << "Manager #\tSales\tSalary\tBest\n";
  104.     std::cout << "\t1\t" << manager1 << " \t" << salary1 << " \t " << (best1 ? "V\n" : "\n");
  105.     std::cout << "\t2\t" << manager2 << " \t" << salary2 << " \t " << (best2 ? "V\n" : "\n");
  106.     std::cout << "\t3\t" << manager3 << " \t" << salary3 << " \t " << (best3 ? "V\n" : "\n");
  107.  
  108.     return 0;
  109. }
RAW Paste Data