AreWe

Untitled

Nov 3rd, 2019
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp12
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. double expNeeded = double.Parse(Console.ReadLine());
  10. int countBattles = int.Parse(Console.ReadLine());
  11. double currentExp = 0;
  12.  
  13. for(int i=1; i<=countBattles; i++)
  14. {
  15. double expPerBattle = double.Parse(Console.ReadLine());
  16. bool isThird = false, isFifth = false;
  17. if (i % 3 == 0) isThird = true;
  18. if (i % 5 == 0) isFifth = true;
  19.  
  20. if (isThird && isFifth) currentExp += expPerBattle * 1.05; // samo 5% bonus
  21. else if (isThird) currentExp += expPerBattle * 1.15; // bonus 15%
  22. else if (isFifth) currentExp += expPerBattle * 0.90; // minus 10%
  23. else currentExp += expPerBattle;
  24.  
  25. if (currentExp >= expNeeded)
  26. {
  27. Console.WriteLine($"Player successfully collected his needed experience for {i} battles.");
  28. break;
  29. }
  30. }
  31.  
  32. if(expNeeded > currentExp) Console.WriteLine($"Player was not able to collect the needed experience, {(expNeeded - currentExp):F2} more needed.");
  33.  
  34. Console.ReadKey();
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment