Create a new BlueJ project called your username-A1Q5. For example, mine would be nfrancis10-A1Q5.
Inside the project you will need to create two classes, which is PartA and PartB.
Part A:
Imagine you need to open a standard three digit combination dial lock. Write a Java program in BlueJ with a method that prints all of the possible combinations. If the three digits combination have all the same number, replace it with “jackpot”. Assume the numbers on each dial range from zero to nine and three numbers in sequence are needed to open the lock. For example, the output would look like:
0-0-0 -> “jackpot”
0-0-1
0-0-2 ->
// lots more combinations 9-9-8 ->
9-9-9 -> “jackpot”
Part B:
Suppose the lock isn’t a very good one and any number that’s no more than one away from the correct number in each digit will also work.
Write another method that takes 3 parameters of type int that are the combination of the lock. The method will print out a minimal list of combinations you would need to try to guarantee opening the lock.
For example, if the combination is 7-6-3 then 7-5-4, 6-6-2, 8-5-3 and other combinations will also open the lock. The first combination printed would be 6-5-2 and the last would be 8-7-
- You will also need to make sure that no number in the combinations that are printed is less that zero and greater than nine as the numbers on each dial range from zero to nine.
The post Create a new BlueJ project appeared first on My Assignment Online.