Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1: Color-Code Authentication as State Machine Write a program that receives input from the user to match a color code used to gain access

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Problem 1: Color-Code Authentication as State Machine Write a program that receives input from the user to match a color code used to gain access to a door. Users have a maximum of 4 incorrect tries before the system exits. Users must enter 4 correct consecutive color-codes to be granted access. The correct code is: Red, Green, Blue, Red. This system can be modeled using the state diagram presented below. Users can input a color value and must match the correct sequence of 4-colors. maxedOut = false; access Granted = false; ColorType c; Start RedOne C = Green c Red c!= Green Initial Green C = Blue C = Red cl Blue c! = Red Error Blue c!= Red C = Red; RedTwo accessGranted = true; ++tryCounter = MaxTries; maxed Out = true; O End The sample output of the main (success) use-case is provided below. Green Red ( to select) (1 to select) Blue (2 to select) Yellow (3 to select) Enter color code: 0 Red was selected. Enter color code: 1 Green was selected. Enter color code: 2 Blue was selected. Enter color code: 0 Red was selected. Red, Greed, Blue, Red is the correct code! Access granted! Incorrect color-code sequence shall deny access to users. The output for alternate use-case where an incorrect color-code sequence is entered is presented below. Red ( to select) Green (1 to select) Blue (2 to select) Yellow (3 to select) Enter color code: 1 Green was selected. Enter color code: 1 Green was selected. Enter color code: 1 Green was selected. Enter color code: 1 Green was selected. Maximum number of attempts reached. Good bye! As seen, users have a maximum of 4 consecutive incorrect entries before the system rejects users and terminates the program. Another example... Red ( to select) Green (1 to select) Blue (2 to select) Yellow (3 to select) Enter color code: 4 Invalid Color was selected. Enter color code: 5 Invalid Color was selected. Enter color code: 6 Invalid Color was selected. Enter color code: 0 Red was selected. Enter color code: 1 Green was selected. Enter color code: 2 Blue was selected. Enter color code: 0 Red was selected. Red, Greed, Blue, Red is the correct code! Access granted! After completion of this problem, you should be able to master the following: Declaring and using variables Input/output in C++ using the cin and cout objects Input/output in C++ using the stream insertion operators . Write programs that repeat blocks of code using the while iteration statement Write programs that alter the flow of control using the switch multiple-selection statements Use the switch multiple-selection statement to implement a state diagram. Use typedef to increase reliability and readability of programs Use conditional statements (e.g., if...else, or if...else if ) Understand how the case, break, and default keywords are used within switch statements Develop problem-solving skills by design and implementing high-level state machines This skills listed above are necessary to succeed in the next assignments and you will be required to prove mastery via quiz and exams. o Getting Started 1. Download the starter file set. It will contain the following files: o main.cpp catch.hpp 2. Use your favorite IDE or editor to modify your files. Include the given files in a project or compile them using your compiler of choice. 3. If you try running the program it will tell you that it has failed all the tests. 4. Your goal is to make the program pass all the tests by completing the assignment. Your code should be placed in between the startRecording and stopRecording calls. We will be using the Catch unit testing framework to grade your solution. When compiling the program for the first time you should get the following message: ======== ========= test cases: 4 4 failed assertions: 4 4 failed Once you have completed the assignment your goal is to pass all the tests and obtain this output: All tests passed (4 assertion in 4 test case) This is provided for you get feedback on your code. You attempt to fix it and prepare it for submission once passes all the tests. Once submitted, a set of similar tests will be run on your solution. Visit the Catch information page to learn more about the details of the automated grading process used for this problem. Submission You are expected to submit your a zip file in Canvas by the specified deadline. The zip file name must match your Tracks ID. For instance, if your Tracks ID is aLastname 2016 then your zip file should be called a Lastname2016.zip. The zip file should only contain the main.cpp file. Submit using the following link. Problem 1: Color-Code Authentication as State Machine Write a program that receives input from the user to match a color code used to gain access to a door. Users have a maximum of 4 incorrect tries before the system exits. Users must enter 4 correct consecutive color-codes to be granted access. The correct code is: Red, Green, Blue, Red. This system can be modeled using the state diagram presented below. Users can input a color value and must match the correct sequence of 4-colors. maxedOut = false; access Granted = false; ColorType c; Start RedOne C = Green c Red c!= Green Initial Green C = Blue C = Red cl Blue c! = Red Error Blue c!= Red C = Red; RedTwo accessGranted = true; ++tryCounter = MaxTries; maxed Out = true; O End The sample output of the main (success) use-case is provided below. Green Red ( to select) (1 to select) Blue (2 to select) Yellow (3 to select) Enter color code: 0 Red was selected. Enter color code: 1 Green was selected. Enter color code: 2 Blue was selected. Enter color code: 0 Red was selected. Red, Greed, Blue, Red is the correct code! Access granted! Incorrect color-code sequence shall deny access to users. The output for alternate use-case where an incorrect color-code sequence is entered is presented below. Red ( to select) Green (1 to select) Blue (2 to select) Yellow (3 to select) Enter color code: 1 Green was selected. Enter color code: 1 Green was selected. Enter color code: 1 Green was selected. Enter color code: 1 Green was selected. Maximum number of attempts reached. Good bye! As seen, users have a maximum of 4 consecutive incorrect entries before the system rejects users and terminates the program. Another example... Red ( to select) Green (1 to select) Blue (2 to select) Yellow (3 to select) Enter color code: 4 Invalid Color was selected. Enter color code: 5 Invalid Color was selected. Enter color code: 6 Invalid Color was selected. Enter color code: 0 Red was selected. Enter color code: 1 Green was selected. Enter color code: 2 Blue was selected. Enter color code: 0 Red was selected. Red, Greed, Blue, Red is the correct code! Access granted! After completion of this problem, you should be able to master the following: Declaring and using variables Input/output in C++ using the cin and cout objects Input/output in C++ using the stream insertion operators . Write programs that repeat blocks of code using the while iteration statement Write programs that alter the flow of control using the switch multiple-selection statements Use the switch multiple-selection statement to implement a state diagram. Use typedef to increase reliability and readability of programs Use conditional statements (e.g., if...else, or if...else if ) Understand how the case, break, and default keywords are used within switch statements Develop problem-solving skills by design and implementing high-level state machines This skills listed above are necessary to succeed in the next assignments and you will be required to prove mastery via quiz and exams. o Getting Started 1. Download the starter file set. It will contain the following files: o main.cpp catch.hpp 2. Use your favorite IDE or editor to modify your files. Include the given files in a project or compile them using your compiler of choice. 3. If you try running the program it will tell you that it has failed all the tests. 4. Your goal is to make the program pass all the tests by completing the assignment. Your code should be placed in between the startRecording and stopRecording calls. We will be using the Catch unit testing framework to grade your solution. When compiling the program for the first time you should get the following message: ======== ========= test cases: 4 4 failed assertions: 4 4 failed Once you have completed the assignment your goal is to pass all the tests and obtain this output: All tests passed (4 assertion in 4 test case) This is provided for you get feedback on your code. You attempt to fix it and prepare it for submission once passes all the tests. Once submitted, a set of similar tests will be run on your solution. Visit the Catch information page to learn more about the details of the automated grading process used for this problem. Submission You are expected to submit your a zip file in Canvas by the specified deadline. The zip file name must match your Tracks ID. For instance, if your Tracks ID is aLastname 2016 then your zip file should be called a Lastname2016.zip. The zip file should only contain the main.cpp file. Submit using the following link

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

Students also viewed these Databases questions