Advertisement
BigInteger

Basdon level calc

Aug 16th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.60 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int maxHoursRank[20] = {5, 10, 20, 40, 50, 50, 50, 100, 100, 100, 200, 200, 200, 400, 400, 400, 400, 400, 500, 500};
  6.  
  7. struct NameBonus
  8. {
  9.     string name;
  10.     int bonus;
  11. };
  12.  
  13. NameBonus names[2] =
  14. {
  15.     {"robin", 5688},
  16.     {"biginteger", 3673}
  17. };
  18.  
  19. void getLevelProgress(string name, int days, int hours, int userbonus)
  20. {
  21.     int bonus = userbonus;
  22.     if (name.compare("0") == 1)
  23.     {
  24.         for (int i = 0; i < sizeof(names) / 8; i++)
  25.         {
  26.             if (names[i].name.compare(name) == 0)
  27.             {
  28.                 bonus += names[i].bonus;
  29.                 break;
  30.             }
  31.         }
  32.     }
  33.     int total = (24 * days) + hours + bonus;
  34.     int current = 0;
  35.     int rank = 0;
  36.     float percentage;
  37.  
  38.     while (current < total)
  39.     {
  40.         if (rank <= 20) current += maxHoursRank[rank];
  41.         else current += 1000;
  42.         rank++;
  43.     }
  44.     if (rank > 20) percentage = (1000 - ((float)current - (float)total)) / 10;
  45.     else percentage = (((float)maxHoursRank[rank - 1] - ((float)current - (float)total)) / ((float)maxHoursRank[rank - 1])) * 100;
  46.  
  47.     cout << "Level: " << rank << ", Percentage: " << percentage << "\n\n";
  48. }
  49.  
  50. int main()
  51. {
  52.     while (1 != 2)
  53.     {
  54.         string name;
  55.         int days;
  56.         int hours;
  57.         int bonus;
  58.         cout << "Name: ";
  59.         cin >> name;
  60.         cout << "Days: ";
  61.         cin >> days;
  62.         cout << "Hours: ";
  63.         cin >> hours;
  64.         cout << "Bonus: ";
  65.         cin >> bonus;
  66.         getLevelProgress(name, days, hours, bonus);
  67.     }
  68.     return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement