desislava_topuzakova

Untitled

Feb 28th, 2022
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp4
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9.  
  10. int locations = int.Parse(Console.ReadLine());
  11. double goldCollected = 0;
  12.  
  13. for (int loc = 1; loc <= locations; loc++)
  14. {
  15. goldCollected = 0;
  16. double expectedGold = double.Parse(Console.ReadLine());
  17. int daysAtaLocation = int.Parse(Console.ReadLine());
  18.  
  19. for (int day = 1; day <= daysAtaLocation; day++)
  20. {
  21. double goldForTheDay = double.Parse(Console.ReadLine());
  22. goldCollected += goldForTheDay;
  23. }
  24. double averageGold = goldCollected / daysAtaLocation;
  25.  
  26. if (averageGold >= expectedGold)
  27. {
  28. Console.WriteLine($"Good job! Average gold per day: {averageGold:f2}.");
  29. }
  30. else
  31. {
  32. Console.WriteLine($"You need {expectedGold-averageGold:f2} gold.");
  33.  
  34. }
  35. }
  36.  
  37.  
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment