Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is part of a C code. I have a problem with a loop in my code. Please help me to fix this part of

This is part of a C code. I have a problem with a loop in my code. Please help me to fix this part of the code so that the output will be as in the first picture. Now the loop is ending earlier than i need to.

You don't have to fix my code, I just need to find out where the error is and how can I fix it.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
Selection: 2 ERROR: Value must be between 0 and 1 inclusive: 0 Are you sure you want to exit? ( [Y]es | [Njo) : n Account Ticketing System - Login 1) Login to the system 0) Exit application Selection: 1 Enter the account#: 30004 User Login : agentJ Password TT* &21tt INVALID user login/password combination! [attempts remaining: 2] Enter the account#: 50008 User Login userMayEnterAVeryLongLogonName Password : TT* &21tt Script done, file is output. txt Checking output : In line number 40 of your output: The output should be: INVALID user login/password combination! [attempts remaining: 1] A But your output is:Selection: 1 Enter the account#: 30004 User Login : agentJ SDDS School of Software Design and Data Science SDDS Fall - 2021 Password : TT*&21tt INVALID user login/password combination! [attempts remaining : 2] Enter the account#: 50008 User Login . . userMayEnterAVeryLongLogonName Password TT*&21tt INVALID user login/password combination! [attempts remaining: 1] Enter the account#: 50008 User Login .. agentJ Password : userMayEnterAVeryLongPasswordValue INVALID user login/password combination! [attempts remaining: 0] ERROR: Access Denied.int menulogin (const struct Account account , int arraynum) { char answer, trylog[11], trypass[9]; int option, accountnum = 0, indexnum = -2, attempts = 3; printf ("======== ====== \ Account Ticketing System - Login\ =========== ======== \ 1) Login to the s printf("0) Exit application\ - -- - - - --\ \ Selection: "); option = getIntFromRange(0, 1); if (option = = 0) printf("\ Are you sure you want to exit? ([Y]es | [Njo) : "); answer = getCharOption("yYnN" ) ; if (answer == 'y' | | answer == 'Y' ) indexnum = -1; else printf ("\ "); else if (option == 1) for (attempts = 2; attempts >= 0; attempts- -) // Login attemts printf("\ Enter the account#: "); accountnum = getInteger ( ) ; indexnum = findAccountIndexByAcctNum(accountnum, account, arraynum, 0) ; printf ("User Login : ") ; getCString(trylog, 1, 30); printf( "Password ") ; getCString(trypass, 1, 30); if (indexnum == -1 | | stromp(trylog, account [indexnum] . userloginfo. loginn) != 0 | stromp(trypass, account [indexnum] . userloginfo. password) != 0) printf("INVALID user login/password combination! [attempts remaining:%%d]\ ", attempts); indexnum = -2; } else attempts -= 3; Activate Winelse if (option == 1) { for (attempts = 2; attempts >= 0; attempts--) // Login attemts printf("\ Enter the account#: "); accountnum = getInteger( ) ; indexnum = findAccountIndexByAcctNum(accountnum, account, arraynum, 0) ; printf("User Login : "); getCString(trylog, 1, 30); printf ( "Password : "); getCString (trypass, 1, 30); if (indexnum == -1 | | stremp(trylog, account [indexnum] . userloginfo. loginn) != 0 | stromp(trypass, account [indexnum] . userloginfo. password) != 0) printf("INVALID user login/password combination! [attempts remaining: %%d]\ ", attempts); indexnum = -2; else attempts -= 3; w - - - if (indexnum == -2) printf("\ ERROR: Login failed! \ \ "); pauseExecution ( ) ; LP return indexnum

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions