Question
C# CODING/ VISUAL STUDIOS Write a console application that prompts users to input a password, Password#1 users should have three 3 opportunities to input the
C# CODING/ VISUAL STUDIOS
Write a console application that prompts users to input a password, Password#1 users should have three 3 opportunities to input the correct password. If a user inputs three 3 incorrect passwords, a message should display indicating that access is denied due to too many unsuccessful login attempts the program should gracefully close following this message.
Should a user supply the correct password, the application should simply print an access granted message prior to gracefully closing.
Your application should include a method that checks a user-provided password for validity and also tracks the numbers of unsuccessful login attempts.
//THIS WHAT I GOT SO FAR BUT CANT FIGURE OUT REST
public static void Main(string[] args) { string password = "Password#1"; string input; bool passSuccess, loginFail; int attempts = 0; do { Console.WriteLine("Please input password"); input = Console.ReadLine(); passSuccess =passCheck(input,password); attempts++; loginFail = loginCount(attempts); } while (!passSuccess && !loginFail); Console.WriteLine(); Console.WriteLine("Please [ENTER] to quit"); Console.ReadKey(); } } } private static bool passCheck(String inputPass, String sysPass) { if (inputPass.Equals(sysPass)) { return true; } else return false; } private static bool loginCount(int numOfLogins) { if (numOfLogins == 3) { return true; } else return false; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started