Lab on if's and mathematical expressions Goals: * To use program design techniques to tackle more sophitiscated specifications * To develop more sophisticated Java classes * To develop programs using mathematical expressions * To develop programs using conditional structures (if's) * To develop test suites and create test methods for code with ifs For each project, make sure that each class has a test class, that this test class is used to thoroughly test its target class, and that the results from this testing are documented in the target class. You may want to have printed copies of your some/partial projects, in case there is an open-notes quiz about these topics. 1. Complete all Chapter 2 exercises. Only two challenge exercises of your choice are required. 2. Implement the following enhancements to the Student class of the lab-classes project in Chapter 1: a. Add a method with the following signature /** * Returns the class standing of the student, as follows: * "frosh" -- credits < 30 * "soph" -- 30 <= credits < 60 * "jr" -- 60 <= credits < 90 * "sr" -- credits > 90 * * @return "frosh", "soph", "jr", or "sr", * depending on the range where credits falls */ public String getStudClass () b. (Before your move on to this problem, make sure you have thoroughly tested and documented the problem in part a.) 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 several mutators to class so that it 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. (If you need to, you may assume that the grade values are all different.) 3. Create a FancyInt class project under h:\ioop\lab04\fancyInt. This class should have a single private field to store an int value. 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. The class should implement this feature via a constructor with the following signature: /** * constructor * * @param initialValue the initial value of this */ public FancyInt (int initialValue) b. A feature that returns the value of _this_ FancyInt object. The class should implement this feature via a public method with the following signature: /** * returns the value of this FancyInt object * * @return the 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: /** * returns true when _this_ FancyInt object is positive; * otherwise, returns false * * @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 this FancyInt object is even. Please use a method signature similar to the one used for isPositive. e. A feature that views the value of this FancyInt object as a temperature in degrees Celsius and returns its Fahrenheit equivalent. The class should implement this feature via a method with the following signature: /** * Views _this_ FancyInt object as a temperature in degrees Celsius and * returns the Fahrenheit equivalent of _this_ * * @return the Fahrenheit equivalent of _this_ */ public double getFahrenheit () f. A feature that views the value of _this_ FancyInt object as a temperature in degrees Fahrenheit and returns its Celsius equivalent. g. A feature that views the value of _this_ FancyInt object 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 this FancyInt object 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 this FancyInt object 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 greatest common divisor of this FancyInt onject and another FancyInt. The class should implement this feature via a method with the following signature: /** * returns the greatest common divisor of this FancyInt object and f * * @return the greatest common divisor of _this_ and f */ public int getGCD (FancyInt f) k. A feature that returns the set of all the divisors of this FancyInt object . The class should implement this feature via a method with the following signature: /** * returns the set of all divisors of this FancyInt object * * @return the set of all divisors of _this_ */ public HashSet getDivisors () l. A feature that returns the binary equivalent of the value of this FancyInt object. The class should implement this feature via a method with the following signature: /** * Converts the decimal value of _this_ to binary. When _this_ is positive, * returns a String of '0's and/or '1's with its binary equivalent; when * _this_ is negative, returns the empty String. * * @return when _this_ is positive, a String of '0's and/or '1's * with its binary equivalent; otherwise, the empty String */ public String getBinaryString () m. 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: /** * returns the equivalent BinaryNumber of _this_ * * @return the equivalent BinaryNumber of _this_ */ public BinaryNumber getBinaryNumber () To accomplish this task, you will need to implement your own BinaryNumber class. 4. Extra credit: 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?