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 _06.CottegeScrapper
- {
- class CottageScrapper
- {
- static void Main(string[] args)
- {
- string line = Console.ReadLine();
- List<KeyValuePair<string, int>> Data = new List<KeyValuePair<string, int>>();
- while (line !="chop chop")
- {
- string[] tokens = line.Split(new string[] { " -> " }, StringSplitOptions.RemoveEmptyEntries);
- string woodType = tokens[0];
- int meters = int.Parse(tokens[1]);
- Data.Add(new KeyValuePair<string, int>(woodType, meters));
- line = Console.ReadLine();
- }
- string neededWood = Console.ReadLine();
- double minMeters = double.Parse(Console.ReadLine());
- double averageSum =Math.Round( Data.Average(a => a.Value),2);
- double usedLogsPrice = Data.Where(a => a.Value >= minMeters && a.Key == neededWood).Sum(a => a.Value);
- double unUsedLogsPrice = Data.Where(a => a.Value < minMeters || a.Key != neededWood).Sum(a => a.Value);
- usedLogsPrice = Math.Round(usedLogsPrice * averageSum, 2);
- unUsedLogsPrice = Math.Round(unUsedLogsPrice * averageSum * 0.25, 2);
- double total = Math.Round(unUsedLogsPrice + usedLogsPrice, 2);
- Console.WriteLine($"Price per meter: ${averageSum:f2}");
- Console.WriteLine($"Used logs price: ${usedLogsPrice :f2}");
- Console.WriteLine($"Unused logs price: ${unUsedLogsPrice:f2}");
- Console.WriteLine($"CottageScraper subtotal: ${total:f2}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement