Somo4k

06.Gold-mine

Jun 14th, 2021 (edited)
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _06.GoldDigging
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int numLocations = int.Parse(Console.ReadLine());
  10.  
  11. for (int i = 1; i <= numLocations; i++)
  12. {
  13. double goldExpected = double.Parse(Console.ReadLine());
  14. double diggingDays = double.Parse(Console.ReadLine());
  15. double goldperDay = 0;
  16.  
  17. for (int j = 1; j <= diggingDays; j++)
  18. {
  19. goldperDay += double.Parse(Console.ReadLine());
  20. }
  21.  
  22. goldperDay /= diggingDays;
  23. if (goldperDay >= goldExpected)
  24. {
  25. Console.WriteLine($"Good job! Average gold per day: {goldperDay:F2}.");
  26. }
  27. else
  28. {
  29. Console.WriteLine($"You need {goldExpected - goldperDay:f2} gold.");
  30. }
  31. }
  32. }
  33. }
  34. }
  35.  
Add Comment
Please, Sign In to add comment