Answer to Question #298928 in Java | JSP | JSF for abhirami

Question #298928

1)  Imagine you need to open a standard combination dial lock but don't know the combination and don't have a pair of bolt cutters. Write a program that prints all possible combinations so you can print them on a piece of paper and check off each one as you try it. Assume the numbers on the dial range from zero to thirty-six and three numbers in sequence are needed to open the lock.

         Suppose the lock isn't a very good one and any number that's no more than one away from the correct number will also work. In other words if the combination is 17-6-32 then 18-5-31 will also open the lock. Write a program that prints the minimum number of combinations you need to try to guarantee opening the lock.


1
Expert's answer
2022-02-18T17:05:29-0500
public class Main {
    public static void main(String[] args) {
        for (int i = 0; i < 36; i +=2) {
            for (int j = 0; j < 36; j+=2) {
                for (int k = 0; k <36; k+=2) {
                    System.out.println(i + "-" + j + "-" + k);
                }
            }
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS