Guest User

Untitled

a guest
Mar 10th, 2017
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. public class Program
  5. {
  6. public static void Main()
  7. {
  8. Console.WriteLine("Hello World");
  9.  
  10. var userEntries = new Dictionary<string,string>();
  11.  
  12. var line = Console.ReadLine();
  13.  
  14. var count = 0;
  15.  
  16. while(line != "login")
  17. {
  18. var input=line.Split();
  19. var username = input [0];
  20. var password = input [input.Length - 1];
  21. userEntries[username] = password;
  22.  
  23. line = Console.ReadLine();
  24.  
  25. }
  26.  
  27. line = Console.ReadLine();
  28.  
  29. while(line != "end")
  30. {
  31. var input=line.Split();
  32. var logInUsername = input [0];
  33. var logInPassword = input [input.Length - 1];
  34.  
  35. if (!userEntries.ContainsKey(logInUsername) || !userEntries.ContainsValue(logInPassword))
  36. {
  37. Console.WriteLine("{0}: login failed",logInUsername);
  38. count ++;
  39. }
  40.  
  41. else
  42.  
  43. {
  44. Console.WriteLine("{0}: logged in successfully",logInUsername);
  45. }
  46.  
  47. line = Console.ReadLine();
  48. }
  49.  
  50. Console.WriteLine("unsuccessful login attempts: {0}",count);
  51.  
  52. }
  53. }
Add Comment
Please, Sign In to add comment