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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started