Advertisement
YavorGrancharov

Filter_Base(copy)(dict)

Jul 11th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Filter_Base
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             string[] input = Console.ReadLine().Split(new char[] { ' ', '-', '>' }, StringSplitOptions.RemoveEmptyEntries);
  12.             Dictionary<string, string> positions = new Dictionary<string, string>();
  13.             Dictionary<string, int> age = new Dictionary<string, int>();
  14.             Dictionary<string, double> salary = new Dictionary<string, double>();
  15.  
  16.             while (input[0] != "filter")
  17.             {
  18.                 string key = input[0];
  19.                 string value = input[1];
  20.  
  21.                 int Age;
  22.                 double Salary;
  23.                 if (int.TryParse(value, out Age))
  24.                 {
  25.                     age[key] = Age;
  26.                 }
  27.                 else if (double.TryParse(value, out Salary))
  28.                 {
  29.                     salary[key] = Salary;
  30.                 }
  31.                 else
  32.                 {
  33.                     positions[key] = value;
  34.                 }
  35.                 input = Console.ReadLine().Split(new char[] { ' ', '-', '>' }, StringSplitOptions.RemoveEmptyEntries);
  36.             }
  37.  
  38.             string end = Console.ReadLine().ToLower();
  39.             if (end == "position")
  40.             {
  41.                 foreach (KeyValuePair<string, string> emloee in positions)
  42.                 {
  43.                     Console.WriteLine($"Name: {emloee.Key}");
  44.                     Console.WriteLine($"Position: {emloee.Value}");
  45.                     Console.WriteLine(new string('=', 20));
  46.                 }
  47.             }
  48.             else if (end == "age")
  49.             {
  50.                 foreach (KeyValuePair<string, int> emloee in age)
  51.                 {
  52.                     Console.WriteLine($"Name: {emloee.Key}");
  53.                     Console.WriteLine($"Age: {emloee.Value}");
  54.                     Console.WriteLine(new string('=', 20));
  55.                 }
  56.             }
  57.             else if (end == "salary")
  58.             {
  59.                 foreach (KeyValuePair<string, double> emloee in salary)
  60.                 {
  61.                     Console.WriteLine($"Name: {emloee.Key}");
  62.                     Console.WriteLine($"Salary: {emloee.Value:F2}");
  63.                     Console.WriteLine(new string('=', 20));
  64.                 }
  65.             }
  66.         }
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement