Advertisement
Sim0o0na

3. Arena Tournament

Mar 12th, 2018
606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ArenaTournament
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. double pointsAvailable = double.Parse(Console.ReadLine());
  14. string nameOfTheArena = Console.ReadLine();
  15. string dayOfWeek = Console.ReadLine();
  16. string itemType = Console.ReadLine();
  17.  
  18. double priceForAllItems = 0;
  19.  
  20. switch (itemType)
  21. {
  22. case "Poor":
  23. priceForAllItems = 7000;
  24. break;
  25. case "Normal":
  26. priceForAllItems = 14000;
  27. break;
  28. case "Legendary":
  29. priceForAllItems = 21000;
  30. break;
  31. }
  32.  
  33. // Apply Discount.
  34. double discount = 0;
  35.  
  36. if (nameOfTheArena == "Nagrand" && (dayOfWeek == "Monday" || dayOfWeek == "Wednesday"))
  37. {
  38. discount = 0.05;
  39. }
  40. else if (nameOfTheArena == "Gurubashi" && (dayOfWeek == "Tuesday" || dayOfWeek == "Thursday"))
  41. {
  42. discount = 0.10;
  43. }
  44. else if (nameOfTheArena == "Dire Maul" && (dayOfWeek == "Friday" || dayOfWeek == "Saturday"))
  45. {
  46. discount = 0.07;
  47. }
  48.  
  49. priceForAllItems = priceForAllItems - (priceForAllItems * discount);
  50.  
  51. // Calculate price for one item after discount.
  52. double priceForOneItem = priceForAllItems / 5;
  53.  
  54. // Try to buy 5 items and count how many succeeded.
  55. int successfulPurchases = 0;
  56.  
  57. for (int item = 1; item <= 5 && pointsAvailable >= priceForOneItem; item++)
  58. {
  59. pointsAvailable -= priceForOneItem;
  60. successfulPurchases++;
  61. }
  62.  
  63. // Print to Console.
  64. if (successfulPurchases == 5)
  65. {
  66. Console.WriteLine($"Items bought: {successfulPurchases}");
  67. Console.WriteLine($"Arena points left: {pointsAvailable}");
  68. Console.WriteLine("Success!");
  69. }
  70. else
  71. {
  72. Console.WriteLine($"Items bought: {successfulPurchases}");
  73. Console.WriteLine($"Arena points left: {pointsAvailable}");
  74. Console.WriteLine("Failure!");
  75. }
  76. }
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement