Create a new BlueJ project called your username-A1Q4. For example, mine would be ahendr10-A1Q4. 4 Create a class called LotsOfNumbers, that has one ArrayList field called numbers, which holds a collection of Integers. Make sure you write a description of your new Class in the comments, with your name as author and give the version as the date you last worked on this exercise. Define a constructor that initialises the ArrayList. Note that you can add any other initialisations that you feel are relevant. Create methods to add elements, remove elements and get the number of elements in the collection. Make sure you add tests for errors and sensible error messages. Create a method called printNumbers. This method should loop through the collection and print out the elements (each Integer on one line) as determined by the following rules; • If the Integer is divisible by 3, instead of printing the Integer, it should print divisible by 3 • If the Integer is divisible by 5, instead of printing the Integer, it should print divisible by 5 • If the integer is divisible by both 3 and 5, then it should print divisible by 3 and 5 • If none of the prior criteria are met, then the method should print the Integer element. For example, if the collection contained the Integers 1, 2, 3, 4, 5, 10, 2, 4, 15, 9, then the printout would look like: 1 2 divisible by 3 4 divisible by 5 divisible by 5 2 4 divisible by 3 and 5 divisible by 3 Once you have finished your project, open the terminal window in BlueJ and turn on record method calls. Create a new Numbers object, and then add at least eleven (11) Integers using 5 the add method you wrote. Make sure you don’t use the same collection as my example. You must have an Integer that is divisible by 3, an Integer that is divisible by 5, and an Integer that is divisible by 3 and 5. Demonstrate removing an element using the remove method you wrote, and then find the number of elements using your method. Finally, run your printNumbers method. Copy all your calls into a text file and save it in your BlueJproject folder. Assignment Q5 To be completed in week 5 Part A: Imagine you need to open a standard combination dial lock but don’t know the combination. Write a Java program in BlueJ with a method that prints all of the 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 each dial range from zero to ten and three numbers in sequence are needed to open the lock. For example, the output would look like: 0-0-0 0-0-1 0-0-2 // lots more combinations 10-10-9 10-10-10 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- 4. You will also need to make sure that no number in the combinations that are printed is less that zero and greater than ten as the numbers on each dial range from zero to ten.
Assignment status: Already Solved By Our Experts
(USA, AUS, UK & CA PhD. Writers)