Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Created by SharpDevelop.
- * User: DVasilev
- * Date: 2017/06/16
- * Time: 10:54 AM
- *
- * To change this template use Tools | Options | Coding | Edit Standard Headers.
- */
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace SupermarketDatabase
- {
- class Program
- {
- public static void Main(string[] args)
- {
- //Console.WriteLine("Hello World!");
- var database = new SortedDictionary<string, SortedDictionary<double,double>>();
- var commands = Console.ReadLine().Split(' ').ToList();
- var command = commands[0];
- while (command != "stocked")
- {
- var stock = commands[1];
- if (!database.ContainsKey(stock))
- {
- database[stock] = new SortedDictionary<double,double>();
- }
- var price = double.Parse(commands[2]);
- var quantity = double.Parse(commands[3]);
- var total = price*quantity;
- foreach (var item in database)
- {
- Console.WriteLine("{0}: ${1:F2} * {2} = ${3:F2}",stock,price,quantity,total);
- }
- var totalSum = total;
- if (command == "stocked")
- {
- Console.WriteLine("{0}\nGrand Total: ${1:F2}", new String('-',30),totalSum);
- }
- }
- Console.Write("Press any key to continue . . . ");
- Console.ReadKey(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment