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 _2._5_Login
- {
- class Program
- {
- static void Main(string[] args)
- {
- /* Input: string
- Password will be reversed user name +++
- Until you receive the correct password print on the console “Incorrect password. Try again.”. +++
- When you receive the correct password print “User {username} logged in.” +++
- However on the fourth try if the password is still not correct print “User {username} blocked!” and end the program. +++ */
- string userName = Console.ReadLine();
- string password = string.Empty;
- for (int i = userName.Length -1; i >= 0; i--)
- {
- password += userName[i];
- }
- for (int i = 1; i <= 4; i++)
- {
- string correctPas = Console.ReadLine();
- if (password == correctPas)
- {
- Console.WriteLine($"User {userName} logged in.");
- break;
- }
- if (i <= 3)
- {
- Console.WriteLine("Incorrect password. Try again.");
- }
- else
- {
- Console.WriteLine($"User {userName} blocked!");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment