Question: Write a program which mimics the behavior of a 3-number rotating combination lock. It will ask the user to input three integers, one per line,

Write a program which mimics the behavior of a 3-number rotating combination lock.

It will ask the user to input three integers, one per line, for the three numbers in the lock's unlock sequence.

Then ask the user to enter the number of ticks to turn the lock clockwise, then ask again for the number of ticks to turn the lock counterclockwise, and then again for the number of ticks to turn the lock clockwise again. Then determine if the user's three selections will cause the lock to unlock, if yes then print a congratulations message, if no, print a message that says you have not guessed it correctly and resets the position to 0 and make the user try again indefinitely until it is correct. While loops are needed in the program.

For example, if a lock is programmed with the unlock sequence of 30,10,15, then to open the lock we would (starting at 0) rotate clockwise 10 ticks to read the combination value of 30, then rotate counterclockwise 20 ticks to reach 10, then rotate clockwise 35 ticks to read value 15.

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!