Advertisement
AnastasiyaG

Untitled

Mar 19th, 2020
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3. namespace _3._SoftUni_Bar_Income
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. decimal total = 0;
  10. while (true)
  11. {
  12. string input = Console.ReadLine();
  13. if (input == "end of shift")
  14. { break; }
  15. Regex regex = new Regex(@"%([A-Z][a-z]+)%<([A-Z][a-z]+)>\|([0-9]+)\|(\d+\.?\d*)\$");
  16. MatchCollection valids = regex.Matches(input);
  17.  
  18. foreach (Match item in valids)
  19. {
  20. string count = item.Groups[3].Value;
  21. string price = item.Groups[4].Value;
  22. //Regex regex2 = new Regex(@"\D+");
  23. //string countResult = regex2.Replace(count, "");
  24. //Regex regex3 = new Regex(@"(\D+)\.?\D*)");
  25. //string priceResult = regex3.Replace(price, "");
  26.  
  27. decimal current = decimal.Parse(count) * decimal.Parse(price);
  28. Console.WriteLine($"{item.Groups[1].Value}: {item.Groups[2].Value} - {current:f2}");
  29. total += current;
  30.  
  31.  
  32. }
  33. }
  34. Console.WriteLine($"Total income: {total:f2}");
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement