I'm working on an assigment for school, and I am totally lost on how to calculate the termination rate. I have a lot of information here, the instructions. Two sets of instructions actually. I have been looking at this for hours now, and i'm to the point where looking at it, is just making it worse. Below this line is where I need to start working. I cannot change anything above this line.
// REMOVE these comments supply the right
// expected values for the next four test cases
here are the instructions... I could just use a friendly nudge in the right directions. I think I need to use the equation provided, and calculate so I can enter the correct values. It's just so much information, I don't even know where to begin, except that I need to calculate something, to put it in the test cases.
Step 4a-2 - Write the test cases for the CalcTermRate() method Remember that the format for testing a method is essentially the same. Create any objects needed. Create the LifeRates object. Set any instance fields. Call the method. Make sure it does what it is supposed to. Ok - what objects need to be created? RateEstimator object - that is one of the instance fields Create the LifeRates object. What instance variables might need to be set? The face value (actually this is done for you) What is the method supposed to do? return the computed term life rate based upon the values provided in the RateEstimator object and the face value. You will need to manually determine what the term life rate should be. Compute this value and enter it into your assertEquals() statements in place of the 0.0. Don't forget that the face value must be between 100,000 and 500,000, so if any of your face values are outside of that range, you shoud be expecting an invalid value return.
The monthly rate of a term life policy will be based on the monthly rate for $100,000 (referred to as the base rate for a given set of customer attributes) extrapolated for the requested face value. A discount is offered depending on the amount the face value exceeds $100,000. A table like the one below determines the discount rate. Category Rate
100,000 < face value < 200,000 95%
200,000 ≤ face value < 300,000 88%
300,000 ≤ face value < 400,000 83.5%
400,000 ≤ face value < 500,000 80%
500,000 ≤ face value < 600,000 75%
Thus, if the base rate for a given candidate is $125.00 (the base rate comes from a call on a method of RateEstimator), and the candidate desired a $340,000 face value term life policy, the monthly rate calculation would be: (125.00 + (125.00 * (340000 – 100000) / 100000)) * .835 Whole life insurance will be offered (again with $100,000 to $600,000 face value). The whole life monthly rate is 2.64 times the monthly rate for the equivalent face value of term life.
In addition, the LifeRates class is to have a method to calculate the surrender value for a whole life policy. Whole life payments are compounded monthly at an annual rate of 5%. The day after 20 years, the insured will receive the face value of the whole life policy. If the insured surrenders the policy before the end of 20 years, he/she will receive a portion of the compounded value as follows:
Category Percentage 0 – 60 months 0% of compounded value 61 – 120 months 23% of compounded value 121 – 180 months 48% of compounded value 181 – 240 months 75% of compounded value
240 months Face value of the policy The whole life surrender value calculation will require the whole life base rate as well as a surrender (termination) month as input. The formula for surrender value for a given face value/surrender month can be expressed as: (surrender value pctg)/100.0 * (whole life base rate) * (termination month) * ((1 + (annual rate)/100.0 / 12.0) ^ (termination month)) As an example, for a whole life base rate of $1024.44 with a termination month of 188, the surrender value calculation is: 75/100.0 * 1024.44 * 188 * (1 + 5/100.0/12.0) 188 It is possible for the calculated surrender value to exceed the face value of the policy – in that case, the surrender value is the face value.
Instance variables will be needed for an instance of RateEstimator, for the desired face value, as well as a name instance field to track a quote by name. Another important project enhancement is the ability to store and manage quotes. The class LifeRatesManager will house a collection (a simple array) of LifeRates objects. In addition to a constructor, it should have an add method, a get method by position (position in the collection) and a get method by name. Since an array is a fixed-size collection and the length only tells us the capacity of the array, not how many elements are populated with viable data, a tracking variable is needed that indicates the position of the next available array element. The value of this instance variable is correlated with a count of the LifeRates objects currently in the collection. For this prototype, the capacity of the array is 25 elements.
You think you have a handle on all of these requirements and muse that we are getting closer to a full-fledged, functional proof-of-concept application.
Implementation Notes • When not otherwise provided, instances of LifeRates should be created /.with a null instance of RateEstimator, a face value of $0.00, and with a name that is null. • When the calculation of base monthly rate for term life is invalid, return RateUtility.INVALID • When the calculation of term life rate is invalid, the calculation of the whole life monthly rate should return RateUtility.INVALID • You are required to use a simple array to manage the collection of LifeRates objects.
/**
* Test the calcTermRate method.
*/
@Test
public void testCalcTermRate()
{
// Non smoker, Female, 24, Low Risk, 0 tickets, Good health
RateEstimator candidate = new
RateEstimator(false, 'F', 24, false, 0, "Good");
LifeRates rateTest = new LifeRates("Smith, Pat", candidate, 100000.0);
// Exhaustive testing of all permutations would require many
// tests. This is a small subset of all permutations.
assertEquals(19.00, rateTest.calcTermRate(), DELTA);
rateTest.setFaceValue(133333.33);
assertEquals(24.07, rateTest.calcTermRate(), DELTA);
// REMOVE these comments supply the right
// expected values for the next four test cases
rateTest.setFaceValue(200000.0);
assertEquals(0.0, rateTest.calcTermRate(), DELTA);
rateTest.setFaceValue(399999.99);
assertEquals(0.0, rateTest.calcTermRate(), DELTA);
rateTest.setFaceValue(433333.33);
assertEquals(0.0, rateTest.calcTermRate(), DELTA);
rateTest.setFaceValue(533333.33);
assertEquals(0.0, rateTest.calcTermRate(), DELTA);
// test invalid face values
rateTest.setFaceValue(99999.00);
assertEquals(RateUtility.INVALID,
rateTest.calcTermRate(), DELTA);
rateTest.setFaceValue(600001.00);
assertEquals(RateUtility.INVALID,
rateTest.calcTermRate(), DELTA);
}
Aucun commentaire:
Enregistrer un commentaire