Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- namespace _3._SoftUni_Bar_Income
- {
- class Program
- {
- static void Main(string[] args)
- {
- decimal total = 0;
- while (true)
- {
- string input = Console.ReadLine();
- if (input == "end of shift")
- { break; }
- Regex regex = new Regex(@"%([A-Z][a-z]+)%<([A-Z][a-z]+)>\|([0-9]+)\|(\d+\.?\d*)\$");
- MatchCollection valids = regex.Matches(input);
- foreach (Match item in valids)
- {
- string count = item.Groups[3].Value;
- string price = item.Groups[4].Value;
- //Regex regex2 = new Regex(@"\D+");
- //string countResult = regex2.Replace(count, "");
- //Regex regex3 = new Regex(@"(\D+)\.?\D*)");
- //string priceResult = regex3.Replace(price, "");
- decimal current = decimal.Parse(count) * decimal.Parse(price);
- Console.WriteLine($"{item.Groups[1].Value}: {item.Groups[2].Value} - {current:f2}");
- total += current;
- }
- }
- Console.WriteLine($"Total income: {total:f2}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement