Lab 07: More sophisticated loops Goals: - Design solutions that involve more complex loops - Implement and test methods with more complex loops - Develop a project from scratch. - Use your knowledge of binary representation of positive integers. - Gain exposure to a problem with exponential complexity. - Develop (analyze, design, code, test, document) more sophisticated programs. 0. Complete the FancyInt class from lab03. Make sure to design a good test suite and a test using a test class. 1. A positive integer n is highly composite number if and only if all positive integers less than n have fewer divisors than n. The smallest highly composite numbers are 1, 2, 4, and 6. Enhance the FancyInt class by adding a method with the following signature /** * @return true if this is a highly composite number; otherwise, false */ public boolean isHighlyComposite ( ) Hint: You may want to implement a "helper method" that returns the number of divisors of a given input integer parameter. 2. Complete the BinaryNumber class from lab 03. 3. Develop a BinNumSequenceGenerator class that generates a sequence of all binary numbers with a given number of bits. Your class must implement the following functionality: /** * @param numOfBits is the number of bits in every BinaryNumber in the sequence. * numOfBits must be > 0 */ public BinNumSequenceGenerator (int numOfBits) /** * @return the next binary number in the sequence */ public BinaryNumber getNext ( ) // Pedagogical note: each instance of BinNumSequenceGenerator will have to // keep track of where it is in its sequence... /** * @return how many BinaryNumbers there are in the total sequence, i,e., * 2 to the power of numOfBits_ */ public long lengthOfSequence ( ) // Pedagogical note: What limitations does this method impose on your // implementation? How large can the constructor's actual parameter be? /** @ @return true if there is a next binary number in the sequence; otherwise returns false */ public boolean hasNext ( ) 4. Extra credit Develop an application called PalindromeCounter that, given a value of n provided by its user, computes the number of binary numbers with n digits that are palindromes. Hint: To compute the expected outcome of your test suite, you may want to use the following idea: Let us use the name "P(n) " as a short-hand name for "the number of binary number palindromes of length n." Notice that P(1) = 2 // (0) and (1) P(2) = 2 // (00) and (11) also when i is even and > 2, P(i) = 2 * P(i-2) // all the shorter numbers with // either a '0' or a '1' at each end when i is odd and > 1, P(i) = 2 * P(i-1) // all the shorter even length numbers // with either a '0' or a '1' in the // middle