Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace Furniture
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- var pattern = new Regex(@">>(?<furniture>[A-Za-z]+)<<(?<price>\d+([.]\d+)?)!(?<quantity>\d+)");
- Console.WriteLine("Bought furniture:");
- double totalSum = 0;
- string command;
- while ((command = Console.ReadLine()) != "Purchase")
- {
- if (pattern.IsMatch(command))
- {
- var current = pattern.Match(command);
- Console.WriteLine(current.Groups["furniture"].Value);
- totalSum += double.Parse(current.Groups["price"].Value) * int.Parse(current.Groups["quantity"].Value);
- }
- }
- Console.WriteLine($"Total money spend: {totalSum:f2}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement