Advertisement
YORDAN2347

GoldMine

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