Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

Postgresql 16 Administration Cookbook Solve Real World Database Administration Challenges With 180+ Practical Recipes And Best Practices

Authors: Gianni Ciolli ,Boriss Mejias ,Jimmy Angelakos ,Vibhor Kumar ,Simon Riggs

1st Edition

1835460585, 978-1835460580

More Books

Students also viewed these Databases questions

Question

(c) Can you fit the original model using this type of analysis?

Answered: 1 week ago

Question

What is the environment we are trying to create?

Answered: 1 week ago

Question

How can we visually describe our goals?

Answered: 1 week ago