Question: Three different styles of if-else implementations are shown that implement the exact same function: determining whether a person has entered a combination correctly on a

 Three different styles of if-else implementations are shown that implement the
exact same function: determining whether a person has entered a combination correctly
on a lock. The only difference among them is how the if-else
statements are utilized. Try typing out these programs to try them out!
Discuss the advantages and disadvantages for each style below; consider the following

Three different styles of if-else implementations are shown that implement the exact same function: determining whether a person has entered a combination correctly on a lock. The only difference among them is how the if-else statements are utilized. Try typing out these programs to try them out! Discuss the advantages and disadvantages for each style below; consider the following in your comparisons: Size of the code Readability and understandability of the code Resources used by the code Flexibility and eusability of the code Overall style and efficiency of the code, es consider when data is entered correctly and incorrectly. Style 1: Questions first Style 2: Questions as we go Style 3: Flags Style 1: Questions first Header file: //includes: #include #include Cfile: This program asks the user for the characters to a combination lock. If the user enters all of the numbers correctly. a message will be displayed indicating that the door is unlocked. Otherwise the message that the police have been called will be displayed #include "Main.h" int main(void) const char Lock Number1= "1", LockNumber 2 = '2', LockNumber3 = LockNumber4 = 4 ; char GetNumberi, GetNumber2, GetNumber 3, GetNumberd; printf("Please enter first lock number:"); Get Numberi = getch(); printf(" Please enter second lock number: "); GetNumber2 = getch(); printf(" Please enter third lock numben:"); GetNumber3 = getch printf( Please enter first fourth numben:"); GeeNumber4 = getches 3C (LockNumber1==GetNumber1)&&(Loc Number == GetNumber2)&&(LockNumber == Getliumpers & Leckumber == GetNumber)) print then as been anlocked); 2.5. Princ e Belize has been samene) ch Style 2 questa we go Header file: //includes: #include #include Cfile: This program asks the user for the characters to a combination lock. If the user enters all of the numbers correctly, a message will be displayed indicating that the door is unlocked. Otherwise the message that the police have been called will be displayed. / #include "Main.h" int main(void) const char LockNumberi = "1", Lock Number 2 = LockNumber4 = 4 ; Lock Number 3 = '3', printf("Please enter first lock number:"); if(LockNumberi == getch() printf(" Please enter second lock number: "); if(LockNumber2 == getch ) printf(" Please enter third lock number: "); if(LockNumber3 == getch() printf(" Please enter fourth lock numben:"); if(LockNumber4 == getch()) printf(" The doen has been unlocked else printf(" The police have been summoned"); else print-(" The police have been summoned) eise printf(" The police have been summoned"); eise printf("The police have been summoned'); Fecha Style 2: Flags Header file: //includes: #include #include //defines: #define FALSE #define TRUE 1 C file: This program asks the user for the characters to a combination lock. If the user enters all of the numbers correctly. a message will be displayed indicatine that the door is unlocked. Otherwise the message that the police have been called will be displayed. #include "Main.h" Lockber2 = Lock Number 3 = '3', int main(void) const char Lock Number1 = LockNumber4 = '4'; int Flag = FALSE; printf("Please enter first lock number: if(LockNumberi == getch() printf(" Please enter second lock number: "); if(LockNumber 2 == getch() printf(" Please enter third lock number: "); if(LockNumber == getch() printf(" Please enter fourth lack number: "); if(LockNumber4 == getch()) Flag = TRUE; lag == TRUE) printf(" The door has been unlocked"); prince(in The police have been summoned etche neur B

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!