lab03 Goals: * To use program design techniques to tackle more sophitiscated specifications * To develop more sophisticated Java classes * To create and use meaningful test suites * To develop programs using mathematical expressions * To develop programs using conditional structures (if's) * To (possibly) use online debugging tools * Extra credit questions: To develop programs using loops For each project, make sure that the project folder contains a test suite, that this test suite is used to thoroughly test the project, and that the results from this testing are documented in the project code. You may also want to copy the test suite into your Lab Log, in case there is an open-notes quiz about this topic. 0. Complete all the Chapter 3 exercises. Challenge exercises are required. Some of the exercises, such as 3.13, are not about writing or executing a Java program. Instead, they ask a question. As we discussed before, the "answer" to these exercises should be typed or neatly handwritten in your Lab Log Book (LLB). This LLB can be a simple text document prepared on your favorite word processor. Make sure you print your updated LLB after every lab and bring it to class, in case the professor gives a open-notes quiz! 1. Implement the following enhancements to the Student class of Chapter 2: a. Add a method with the following signature // @return "frosh", "soph", "jr", or "sr", // depending on the range that credits falls into public String getStudClass () b. Add three new private attributes to the class to store the grades received by a Student object on three evaluations. Now modify the existing constructor to give default values to these new attributes. Once this has been completed, add a(several) mutator(s) to class that allows a client to set the values of the evaluations for a Student object. c. Add a new constructor that will receive as parameters the initial values for all private attributes (to do this, copy-and-paste from the current constructor and add three more parameters for the initial values of the grades!). d. Add three accessors that will give a client of the class access to the highest grade value, the lowest grade value, and the middle grade value for a Student object. 2. Implement a ChangeMaker class that will be used to help cashiers give change. Given an amount of money (less than $1) the class should provide a feature to display the best way to give that amount of change. Develop a careful test suite for your class. Test your class with your test suite and document the outcomes. Are you confident that your implementation and Java's arithmetic do not result in precision or roundoff errors? 3. Create a FancyInt class project under h:\ioop\lab03\fancyInt. The class must provide the following functionality: a. A feature that allows a client to create a FancyInt object and give it an initial value as a parameter. b. A feature that returns the value of _this_. The class should implement this feature via a public method with the following signature: // @return value of _this_ public int getValue () Also implement the corresponding mutator, setValue. c. A feature that returns whether or not a FancyInt is positive. The class should implement this feature via a method with the following skeleton: // @return true when _this_ is positive; otherwise, returns false public boolean isPositive () { boolean result; result = true; // dummy result initialization; ??? FIX ME return true; } // isPositive d. A feature that returns whether or not a FancyInt is even. e. A feature that views the value of _this_ as a temperature in degrees Celsius and returns its Fahrenheit equivalent. The class should implement this feature via a method with the following signature: // @return the Fahrenheit equivalent of _this_ public double getFahrenheit () f. A feature that views the value of _this_ as a temperature in degrees Fahrenheit and returns its Celsius equivalent. g. A feature that views the value of _this_ as a year and returns whether or not it is a leap year. Remember that a leap year is a year with 366 days. All leap years are multiples of 4, but not multiples of 100. Years that are multiples of 400 are an exception to the previous rule. For example, 1996 is leap, 1997 is not leap, 1900 is not leap, and 2000 is leap. There are no leap years before 1582 (when the Gregorian calendar and the concept of leap year were introduced). THE REMAINING SECTIONS OF THIS QUESTION are extra credit for this lab. You will not be able to solve them unless you know about loops. These sections will be required later. h. A feature that returns whether or not a FancyInt is prime. Remember that a positive integer is prime when its only divisors are 1 and itself. By convention, the smallest prime number is 2. i. A feature that returns whether or not a FancyInt is perfect. Remember that a positive integer is perfect when the sum of its divisors is (2 * itself). For example, the first perfect number is 6 since (1+2+3+6) = 12 = 2*6. The next perfect number is 28. j. A feature that returns the binary equivalent of the value of _this_. The class should implement this feature via a method with the following signature: // @return when _this_ is positive, a String with its binary equivalent; // otherwise, the empty String public String getBinaryString () k. A feature that returns a BinaryNumber initialized to the binary equivalent of the value of _this_. The class should implement this feature via a method with the following signature: // @return the equivalent BinaryNumber public BinaryNumber getBinaryNumber () To accomplish this task, you will need to implement a BinaryNumber class. l. A feature that returns the greatest common divisor of _this_ and another FancyInt. The class should implement this feature via a method with the following signature: // @return the greatest common divisor of _this_ and f public int getGCD (FancyInt f) m. A feature that returns the set of all the divisors of _this_ . The class should implement this feature via a method with the following signature: // @return the set of all divisors of _this_ public ArrayList getDivisors () 4. EXTRA CREDIT if completed by our next the lab. (This will "be on the test.") a. Develop a BinaryNumber class. This class must implement the method public int decimalEquivalent (); Your class only needs to handle "positive" values, and you may benefit from studying the API for the String class. Didactic note: The purpose of this lab is for you to practice creating and testing your own class, developing an algorithm, and using loops and ifs. In case you find, by any chance, a Java library function that that converts decimal to binary, please DO NOT USE IT and solve the problem from scratch instead.