Advertisement
nevenailievaa

06.GoldMine

Nov 19th, 2022
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.53 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp2
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             //INPUT
  10.             int numberLocations = int.Parse(Console.ReadLine());
  11.  
  12.             //CHANGEABLE INPUT
  13.             double expectedGoldForOneDay = 0;
  14.             int daysAtCurrentLoacation = 0;
  15.  
  16.             double goldForTheDay = 0;
  17.             double goldDaysSum = 0;
  18.             double goldDaysAverage = 0;
  19.  
  20.             //CALCULATIONS
  21.             for (int i = 1; i <= numberLocations; i++)
  22.             {
  23.                 expectedGoldForOneDay = double.Parse(Console.ReadLine());
  24.                 daysAtCurrentLoacation = int.Parse(Console.ReadLine());
  25.  
  26.                 for (int j = 1; j <= daysAtCurrentLoacation; j++)
  27.                 {
  28.                     goldForTheDay = double.Parse(Console.ReadLine());
  29.                     goldDaysSum += goldForTheDay;
  30.                     goldDaysAverage = goldDaysSum / daysAtCurrentLoacation;
  31.                 }
  32.  
  33.                 if (goldDaysAverage >= expectedGoldForOneDay)
  34.                 {
  35.                     Console.WriteLine($"Good job! Average gold per day: {(goldDaysAverage):f2}.");
  36.                 }
  37.                 else
  38.                 {
  39.                     Console.WriteLine($"You need {(expectedGoldForOneDay - goldDaysAverage):f2} gold.");
  40.                 }
  41.  
  42.                 //CLEAR DATA
  43.                 goldForTheDay = 0;
  44.                 goldDaysSum = 0;
  45.                 goldDaysAverage = 0;
  46.             }
  47.         }
  48.     }
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement