2. (45%) Write a C program that simulates a simple password validation system. The program should...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
2. (45%) Write a C program that simulates a simple password validation system. The program should do the following: a. Write a C program that simulates a simple password validation system. The program should do the following: b. Ask the user to enter a password. c. Check if the entered password matches a predefined correct password (e.g., "password123"). d. If the entered password is correct, display a message saying "Access granted" and terminate the program. e. If the entered password is incorrect, allow the user to try again, but limit the number of attempts to 3. f. If the user exceeds 3 incorrect attempts, display a message saying "Access denied" and terminate the program. g. The expected output: i. Assume my password is char correct_password[ ] = "password123"; ii. Read the password (char user_password[20]) from keyboard: scanf("%s", user_password); iii. Check if correct_password is the same as user_password if (strcmp(user_password, correct_password) == 0) iv. Case 1: Enter the password: 123 Incorrect password. Please try again. Enter the password: password123 Access granted v. Case 2: Enter the password: 1 Incorrect password. Please try again. Enter the password: 2 Incorrect password. Please try again. Enter the password: 3 Incorrect password. Please try again. Access denied Hit: In this exercise, you'll need to use the if-else statement to check if the entered password is correct or not. If it's correct, you should use the break statement to exit the loop and grant access. If the password is incorrect, the loop continues until 2. (45%) Write a C program that simulates a simple password validation system. The program should do the following: a. Write a C program that simulates a simple password validation system. The program should do the following: b. Ask the user to enter a password. c. Check if the entered password matches a predefined correct password (e.g., "password123"). d. If the entered password is correct, display a message saying "Access granted" and terminate the program. e. If the entered password is incorrect, allow the user to try again, but limit the number of attempts to 3. f. If the user exceeds 3 incorrect attempts, display a message saying "Access denied" and terminate the program. g. The expected output: i. Assume my password is char correct_password[ ] = "password123"; ii. Read the password (char user_password[20]) from keyboard: scanf("%s", user_password); iii. Check if correct_password is the same as user_password if (strcmp(user_password, correct_password) == 0) iv. Case 1: Enter the password: 123 Incorrect password. Please try again. Enter the password: password123 Access granted v. Case 2: Enter the password: 1 Incorrect password. Please try again. Enter the password: 2 Incorrect password. Please try again. Enter the password: 3 Incorrect password. Please try again. Access denied Hit: In this exercise, you'll need to use the if-else statement to check if the entered password is correct or not. If it's correct, you should use the break statement to exit the loop and grant access. If the password is incorrect, the loop continues until
Expert Answer:
Answer rating: 100% (QA)
The image contains a programming exercise which asks to write a C program for a simple password vali... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Please do the following Matlab problem, 1.Write a for loop ranging from 3 to 5. In the loop, print the value of the loop index to the screen using fprintf in the following format: Value is n where n...
-
There are many ethical dilemmas that could conflict with your personal values. As a future healthcare administrator, how would you navigate an ethical conflict? Describe a personal experience you...
-
Explain what you would assume the yield curve would look like during economic expansion and why.
-
Refer to the data in Problem 5-12A. Required 1. Journalize the adjusting and closing entries. 2. Determine the December 31, 2017, balance of Capital for Marvin's Fine Gems. In Problem 5-12A The trial...
-
On December 1, 2020, Matthias Company had the account balances shown below. The following transactions occurred during December. Dec. 3 Purchased 4,000 units of inventory on account at a cost of...
-
A rigid tank contains a hot fluid that is cooled while being stirred by a paddle wheel. Initially, the internal energy of the fluid is \(800 \mathrm{~kJ}\). During the cooling process the fluid loses...
-
South Carolina Corporation has one temporary difference at the end of 2008 that will reverse and cause taxable amounts of $55,000 in 2009, $60,000 in 2010, and $65,000 in 2011. South Carolinas pretax...
-
Raymond B. Cattell was a psychologist who utilized thestatistical technique of factor analysis to determine underlyingpersonality traits. His definition of personality was very concise:personality is...
-
At the beginning of the year, Carla Vista Company had total assets of $763,000 and total liabilities of $296,000. Answer the following questions. (a) If total assets increased $134,000 during the...
-
Prove the identity V (V F) = V (V F) VF, - where F is a vector field.
-
Problem# 1 (10 pnts): Given the following two alternatives where incremental analysis is required: A1 (5) A2 (5) -3,000 -12,000 1,350 4,200 1,800 6,225 1,500 6,330 0 2 3 IRR AA a) Are you going to go...
-
. You must use the 2022 versions of the tax forms. It is recommended that you refer to the instructions for Form 1040, the schedules, and the additional forms that are available on the IRS Website....
-
2. Half-hours (per month) a) Max enjoys windsurfing and snorkeling. He obtains the following utility from each of these sports: b) 1 2 3 4 5 6 7 8 9 TUW 60 110 150 180 200 206 211 215 218 MUW 60 50...
-
Jason Co is an online computer trader which made annual sales of $ 1 5 , 0 0 0 , 0 0 0 last year. The most recent financial statement indicates the company owns $ 2 , 4 6 6 , 0 0 0 trade receivables,...
-
In this task, you are required to answer the questions by referring to the data table given below. The table shows 15 cases, college students, from a hypothetical study of student loan balances at...
-
An Underwriter buys securities from the issuer and sells them privately or to the public. To diversify the risk of buying the securities and not being able to sell them, the underwriting firm can...
-
Is the modified 5-question approach to ethical decision making superior to the modified moral standards or modified Past in approach?
-
What are the similarities and differences between the BowTie Diagram, the Safety Analysis of the Incident, and the Swiss Cheese Model?
-
Living Example 16-3 Wolfram and Python 1. Vary and find the combination of parameters for which the exit conversion is virtually the same for both early mixing and late mixing. 2. Find the...
-
What assumptions were made in the derivation of the design equation for: (a) The batch reactor (BR)? (b) The CSTR? (c) The plug-flow reactor (PFR)? (d) The packed-bed reactor (PBR)? (e) State in...
-
The same suspension as that in Problem 39 above was subsequently tested in a $28 \mathrm{~mm}$ internal diameter pipe, and the following data reported: $\Gamma\left(\mathrm{s}^{-1} ight)$ 127 200 289...
-
A mercury manometer is connected between two points in a piping system that contains water. The downstream tap is $6 \mathrm{ft}$ higher than the upstream tap, and the manometer reading is $16...
-
The manometer equation is $\Delta \Phi=-\Delta ho g \Delta h$, where $\Delta \Phi$ is the difference in the total pressure plus static head $(P+ho g z)$ between the two points to which the manometer...
Study smarter with the SolutionInn App