Advertisement
Guest User

Untitled

a guest
Apr 4th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication4
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string[] usernames = { "user1", "user2", "user3" };
  14. string[] passwords = { "1111", "2222", "3333" };
  15.  
  16. // data variables
  17. string username = "john";
  18. string password = "doe";
  19. // keyboard input
  20. string user = "";
  21. string pass = "";
  22.  
  23. do {
  24.  
  25. Console.WriteLine("Please enter username:");
  26. user = Console.ReadLine();
  27. Console.WriteLine("Please enter password:");
  28. pass = Console.ReadLine();
  29.  
  30. for (int i = 0; i < usernames.Length; i++)
  31. {
  32. if (user == usernames[i])
  33. {
  34.  
  35. if (pass == passwords[i])
  36. {
  37. Console.WriteLine("Welcome to our system!");
  38. username = usernames[i];
  39. password = passwords[i];
  40. }
  41. else
  42. {
  43. Console.WriteLine("Invalid password");
  44. }
  45.  
  46. }
  47. }
  48.  
  49. } while (username != user || password != pass);
  50.  
  51. Console.ReadKey();
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement