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 Orders
- {
- class Program
- {
- static void Main(string[] args)
- {
- string pattern = @">>(?<name>.+)<<(?<price>\d+\.?\d*)!(?<quantity>\d+)";
- List<string> furniture = new List<string>();
- string input;
- decimal totalSpendMoney = 0;
- decimal sum = 0;
- while ((input = Console.ReadLine()) != "Purchase")
- {
- Match match = Regex.Match(input, pattern);
- if (match.Success)
- {
- string name = match.Groups["name"].Value;
- decimal price = decimal.Parse(match.Groups["price"].Value);
- int quantity = int.Parse(match.Groups["quantity"].Value);
- furniture.Add(name);
- sum = price * quantity;
- totalSpendMoney += sum;
- }
- }
- Console.WriteLine("Bought furniture:");
- foreach (var furnitures in furniture)
- {
- Console.WriteLine(furnitures);
- }
- Console.WriteLine("Total money spend: {0:f2}", totalSpendMoney);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement