Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _04.Problem_MasterHerbalist
- {
- class MasterHerbalist
- {
- static void Main(string[] args)
- {
- uint dailyExpenses = uint.Parse(Console.ReadLine());
- string working = Console.ReadLine();
- decimal totalMoney = 0.0M;
- uint avg = 0;
- int secondCounter = 0;
- while (working != "Season Over")
- {
- string[] splitWorking = working.Split(' ');
- uint hours = uint.Parse(splitWorking[0]);
- string path = splitWorking[1];
- uint herbPrice = uint.Parse(splitWorking[2]);
- uint herbCounter = 0;
- for (int i = 0; i < hours; i++)
- {
- if (hours <= path.Length)
- {
- if (path[i] == 'H')
- {
- herbCounter++;
- }
- }
- else if(hours > path.Length)
- {
- if (i < path.Length)
- {
- if (path[i] == 'H')
- {
- herbCounter++;
- }
- }
- else if(i >= path.Length)
- {
- if (path[secondCounter] == 'H')
- {
- herbCounter++;
- }
- secondCounter++;
- }
- }
- }
- avg++;
- totalMoney += herbCounter * herbPrice;
- working = Console.ReadLine();
- }
- decimal avgPerDay = totalMoney / avg;
- if (avgPerDay >= dailyExpenses)
- {
- decimal extraMoneyPerDay = avgPerDay - dailyExpenses;
- Console.WriteLine("Times are good. Extra money per day: {0:F2}.", extraMoneyPerDay);
- }
- else
- {
- decimal moneyNeed = dailyExpenses - avgPerDay;
- Console.WriteLine("We are in the red. Money needed: {0}.", Math.Floor(moneyNeed * avg));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement