Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace ConsoleApp5
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] products = Console.ReadLine().Split(' ').ToArray();
- ulong[] availability = Console.ReadLine().Split(' ').Select(ulong.Parse).ToArray();
- decimal[] prices = Console.ReadLine().Split(' ').Select(decimal.Parse).ToArray();
- int index = 0;
- while (true)
- {
- string[] product = Console.ReadLine().Split(' ').ToArray();
- if (product[0] == "done")
- {
- break;
- }
- index = Array.IndexOf(products, product[0]);
- try
- {
- if (ulong.Parse(product[1]) <= availability[index])
- {
- Console.WriteLine($"{product[0]} x {product[1]} costs {ulong.Parse(product[1]) * prices[index]}");
- availability[index] -= ulong.Parse(product[1]);
- }
- else
- {
- Console.WriteLine($"We do not have enough {product[0]}");
- }
- }
- catch (Exception)
- {
- Console.WriteLine($"We do not have enough {product[0]}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement