Advertisement
fbinnzhivko

04.00 Master Herbalist

May 4th, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4.     static void Main()
  5.     {
  6.         int dailyExpenses = int.Parse(Console.ReadLine());
  7.         string input = Console.ReadLine();
  8.         int days = 0;
  9.         int totalMoney = 0;
  10.  
  11.         while (input != "Season Over")
  12.         {
  13.             days++;
  14.             string[] parameters = input.Split();
  15.             int hours = int.Parse(parameters[0]);
  16.             string path = parameters[1];
  17.             int price = int.Parse(parameters[2]);
  18.  
  19.             int herbs = 0;
  20.             for (int i = 0; i < hours; i++)
  21.             {
  22.                 if (path[i % path.Length] == 'H')
  23.                 {
  24.                     herbs++;
  25.                 }
  26.             }
  27.             totalMoney = totalMoney + herbs * price;
  28.             input = Console.ReadLine();
  29.         }
  30.         //Console.WriteLine(totalMoney);
  31.         decimal average = (decimal)totalMoney / days;
  32.  
  33.         if (average >= dailyExpenses)
  34.         {
  35.             Console.WriteLine("Times are good. Extra money per day: {0:F2}.", average - dailyExpenses);
  36.         }
  37.         else
  38.         {
  39.             int totalExpenses = dailyExpenses * days;
  40.             Console.WriteLine("We are in the red. Money needed: {0}.", totalExpenses - totalMoney);
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement