Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Text.RegularExpressions;
- namespace SoftUniBarIncome
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = string.Empty;
- string pattern = @"^%(?<name>[A-Z][a-z]+)%[^|$%.]*<(?<product>\w+)>[^|$%.]*\|(?<count>\d+)\|[^|$%.]*?(?<price>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\$";
- double total = 0;
- while ((input = Console.ReadLine()) != "end of shift")
- {
- if (Regex.IsMatch(input, pattern))
- {
- Match digit = Regex.Match(input, pattern);
- string name = digit.Groups["name"].Value;
- string product = digit.Groups["product"].Value;
- int count = int.Parse(digit.Groups["count"].Value);
- double price = double.Parse(digit.Groups["price"].Value);
- double money = price * count;
- Console.WriteLine($"{name}: {product} - {money:f2}");
- total += money;
- }
- }
- Console.WriteLine($"Total income: {total:f2}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement