Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _05Login
- {
- class Program
- {
- static void Main(string[] args)
- {
- string username = Console.ReadLine();
- string password = "";
- for (int i = username.Length - 1; i >= 0; i--)
- {
- password += username[i];
- }
- string currentPassword = Console.ReadLine();
- int invalidPassAttempt = 1;
- while (currentPassword != password)
- {
- Console.WriteLine("Incorrect password. Try again.");
- invalidPassAttempt++;
- if (invalidPassAttempt == 4)
- {
- Console.WriteLine($"User {username} blocked!");
- return;
- }
- currentPassword = Console.ReadLine();
- }
- Console.WriteLine($"User {username} logged in.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement