Advertisement
jordan3900

Untitled

Jul 19th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 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 _06.CottegeScrapper
  8. {
  9. class CottageScrapper
  10. {
  11. static void Main(string[] args)
  12. {
  13. string line = Console.ReadLine();
  14. List<KeyValuePair<string, int>> Data = new List<KeyValuePair<string, int>>();
  15.  
  16. while (line !="chop chop")
  17. {
  18. string[] tokens = line.Split(new string[] { " -> " }, StringSplitOptions.RemoveEmptyEntries);
  19. string woodType = tokens[0];
  20. int meters = int.Parse(tokens[1]);
  21.  
  22. Data.Add(new KeyValuePair<string, int>(woodType, meters));
  23. line = Console.ReadLine();
  24. }
  25. string neededWood = Console.ReadLine();
  26. double minMeters = double.Parse(Console.ReadLine());
  27.  
  28. double averageSum =Math.Round( Data.Average(a => a.Value),2);
  29. double usedLogsPrice = Data.Where(a => a.Value >= minMeters && a.Key == neededWood).Sum(a => a.Value);
  30. double unUsedLogsPrice = Data.Where(a => a.Value < minMeters || a.Key != neededWood).Sum(a => a.Value);
  31.  
  32. usedLogsPrice = Math.Round(usedLogsPrice * averageSum, 2);
  33. unUsedLogsPrice = Math.Round(unUsedLogsPrice * averageSum * 0.25, 2);
  34. double total = Math.Round(unUsedLogsPrice + usedLogsPrice, 2);
  35.  
  36. Console.WriteLine($"Price per meter: ${averageSum:f2}");
  37. Console.WriteLine($"Used logs price: ${usedLogsPrice :f2}");
  38. Console.WriteLine($"Unused logs price: ${unUsedLogsPrice:f2}");
  39. Console.WriteLine($"CottageScraper subtotal: ${total:f2}");
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement