Advertisement
miroLLL

MasterHerbalist

Jan 26th, 2016
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.45 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 _04.Problem_MasterHerbalist
  8. {
  9.     class MasterHerbalist
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             uint dailyExpenses = uint.Parse(Console.ReadLine());
  14.             string working = Console.ReadLine();
  15.             decimal totalMoney = 0.0M;
  16.  
  17.             uint avg = 0;
  18.             int secondCounter = 0;
  19.  
  20.             while (working != "Season Over")
  21.             {
  22.                 string[] splitWorking = working.Split(' ');
  23.                 uint hours = uint.Parse(splitWorking[0]);
  24.                 string path = splitWorking[1];
  25.                 uint herbPrice = uint.Parse(splitWorking[2]);
  26.  
  27.                 uint herbCounter = 0;
  28.                 for (int i = 0; i < hours; i++)
  29.                 {
  30.                    if (hours <= path.Length)
  31.                     {
  32.                         if (path[i] == 'H')
  33.                         {
  34.                             herbCounter++;
  35.                         }
  36.                     }
  37.  
  38.                     else if(hours > path.Length)
  39.                     {
  40.                         if (i < path.Length)
  41.                         {
  42.                             if (path[i] == 'H')
  43.                             {
  44.                                 herbCounter++;
  45.                             }
  46.                         }
  47.  
  48.                         else if(i >= path.Length)
  49.                         {
  50.                             if (path[secondCounter] == 'H')
  51.                             {
  52.                                 herbCounter++;
  53.                             }
  54.                             secondCounter++;
  55.                         }
  56.                     }
  57.                 }
  58.                 avg++;
  59.                 totalMoney += herbCounter * herbPrice;
  60.                 working = Console.ReadLine();
  61.             }
  62.            
  63.             decimal avgPerDay = totalMoney / avg;
  64.  
  65.             if (avgPerDay >= dailyExpenses)
  66.             {
  67.                 decimal extraMoneyPerDay = avgPerDay - dailyExpenses;
  68.                 Console.WriteLine("Times are good. Extra money per day: {0:F2}.", extraMoneyPerDay);
  69.             }
  70.             else
  71.             {
  72.                 decimal moneyNeed = dailyExpenses - avgPerDay;
  73.                 Console.WriteLine("We are in the red. Money needed: {0}.", Math.Floor(moneyNeed * avg));
  74.             }
  75.         }
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement