In: Computer Science
Can you please tell me if this code needs to be fixed, if it does can you please post the fixed code below please and thank you
/**
* Models a Whole Life Policy.
*
* @author Tina Comston
* @version Fall 2019
*/
public class WholeLifePolicy
{
// instance variables
private double faceValue;
// your code here - code the remaining instance field
// constants
/**
* surrender rate.
*/
public static final double SURRENDER_RATE = .65;
/**
* ADMIN FEE.
*/
public static final double ADMIN_FEE = .005;
// constructors and methods
/**
* Default constructor for objects of class WholeLifePolicy.
* This is the default constructor.
*
* Default values are:
* face value = 0.0
* policy years = 0
* policy number WLP9999999
*
*/
public WholeLifePolicy()
{
this.setPolicyNum("WLP9999999");
this.setFaceValue(0.0);
this.setPolicyYrs(0);
}
/**
* Explicit constructor for objects of class WholeLifePolicy.
*
* @param inPolicyNum Number of the policy
* @param inFaceValue Face Value of policy.
* @param inPolicyYrs Length of policy in years.
*
*/
public WholeLifePolicy(String inPolicyNum, double
inFaceValue,
int inPolicyYrs)
{
// your code here, complete the constructor
}
/**
* Copy constructor for objects of class WholeLifePolicy.
* This constructor creates an exact copy of a
* WholeLifePolicy object.
*
* @param inPolicyObject WholeLifePolicy object.
*
*/
public WholeLifePolicy(WholeLifePolicy inPolicyObject)
{
this.setPolicyNum(inPolicyObject.getPolicyNum());
// your code here, complete the constructor
}
/**
* Set the Policy Face Value.
*
* @param inFaceValue Face Value of policy.
*
*/
public void setFaceValue(double inFaceValue)
{
this.faceValue = faceValue;
}
/**
* Get the Policy Face Value.
*
* @return double Face Value of policy.
*
*/
public double getFaceValue()
{
return this.faceValue;
}
/**
* Set the Policy Years.
*
* @param inPolicyYrs Length of policy in years.
*
*/
public void setPolicyYrs(int inPolicyYrs)
{
// your code here, complete the method
}
/**
* Get the Policy Years.
*
* @return int Length of policy in years.
*
*/
public int getPolicyYrs()
{
// your code here, replace the following statement
return 9999;
}
/**
* Set the Policy Number. Use to override the default
* policy number or for copy object processing.
*
* @param inPolicyNum Policy Number.
*
*/
public void setPolicyNum(String inPolicyNum)
{
// your code here, complete the method
}
/**
* Get the Policy Number.
*
* @return String Policy Number.
*
*/
public String getPolicyNum()
{
// your code here, replace the following statement
return "incorrect value";
}
/**
* Calculate surrender value.
* Surrender value is calculated as:
* (surrender rate * face value) *
* (years held / policy years) - amount borrowed -
* (face value * administrative fee)
*
* @param inYrsHeld Length in years policy held to date.
* @param inBorAmt Amount borrowed against policy if any.
*
* @return double Policy surrender value.
*
*/
public double surrenderVal(double inYrsHeld, double inBorAmt)
{
// Termination value is the surrender rate percentage of the
face
// value as a proportion of the years held to policy years less
any
// amount borrowed on the policy less a ADMINFEE on the
// face value.
// your code here, compute the surrender value and replace
the
// following line
return 99999.99;
}
/**
* Return a string representation of the WholeLifePolicy.
*
* @return String output string.
*
* <pre>
* Produce output in the following format:
*
* Policy Information:
* Policy #: WLP1000000
* Policy Years: 20
* Face Value: 50000.0
*
* </pre>
*/
public String toString()
{
String output = "Policy Information:\n";
output = output + "Policy #: " + this.getPolicyNum() + "\n";
// your code here, finish the output string
return output;
}
}
If you have any doubts, please give me comment...
/**
* Models a Whole Life Policy.
*
* @author Tina Comston
* @version Fall 2019
*/
public class WholeLifePolicy {
// instance variables
private double faceValue;
private String policyNum;
private int policyYrs;
// your code here - code the remaining instance field
// constants
/**
* surrender rate.
*/
public static final double SURRENDER_RATE = .65;
/**
* ADMIN FEE.
*/
public static final double ADMIN_FEE = .005;
// constructors and methods
/**
* Default constructor for objects of class WholeLifePolicy. This is the default
* constructor.
*
* Default values are: face value = 0.0 policy years = 0 policy number
* WLP9999999
*
*/
public WholeLifePolicy() {
this.setPolicyNum("WLP9999999");
this.setFaceValue(0.0);
this.setPolicyYrs(0);
}
/**
* Explicit constructor for objects of class WholeLifePolicy.
*
* @param inPolicyNum Number of the policy
* @param inFaceValue Face Value of policy.
* @param inPolicyYrs Length of policy in years.
*
*/
public WholeLifePolicy(String inPolicyNum, double inFaceValue, int inPolicyYrs) {
// your code here, complete the constructor
policyNum = inPolicyNum;
faceValue = inFaceValue;
policyYrs = inPolicyYrs;
}
/**
* Copy constructor for objects of class WholeLifePolicy. This constructor
* creates an exact copy of a WholeLifePolicy object.
*
* @param inPolicyObject WholeLifePolicy object.
*
*/
public WholeLifePolicy(WholeLifePolicy inPolicyObject) {
this.setPolicyNum(inPolicyObject.getPolicyNum());
// your code here, complete the constructor
this.setFaceValue(inPolicyObject.getFaceValue());
this.setPolicyYrs(inPolicyObject.getPolicyYrs());
}
/**
* Set the Policy Face Value.
*
* @param inFaceValue Face Value of policy.
*
*/
public void setFaceValue(double inFaceValue) {
this.faceValue = inFaceValue;
}
/**
* Get the Policy Face Value.
*
* @return double Face Value of policy.
*
*/
public double getFaceValue() {
return this.faceValue;
}
/**
* Set the Policy Years.
*
* @param inPolicyYrs Length of policy in years.
*
*/
public void setPolicyYrs(int inPolicyYrs) {
// your code here, complete the method
policyYrs = inPolicyYrs;
}
/**
* Get the Policy Years.
*
* @return int Length of policy in years.
*
*/
public int getPolicyYrs() {
// your code here, replace the following statement
return policyYrs;
}
/**
* Set the Policy Number. Use to override the default policy number or for copy
* object processing.
*
* @param inPolicyNum Policy Number.
*
*/
public void setPolicyNum(String inPolicyNum) {
// your code here, complete the method
policyNum = inPolicyNum;
}
/**
* Get the Policy Number.
*
* @return String Policy Number.
*
*/
public String getPolicyNum() {
// your code here, replace the following statement
return policyNum;
}
/**
* Calculate surrender value. Surrender value is calculated as: (surrender rate
* * face value) * (years held / policy years) - amount borrowed - (face value *
* administrative fee)
*
* @param inYrsHeld Length in years policy held to date.
* @param inBorAmt Amount borrowed against policy if any.
*
* @return double Policy surrender value.
*
*/
public double surrenderVal(double inYrsHeld, double inBorAmt) {
// Termination value is the surrender rate percentage of the face
// value as a proportion of the years held to policy years less any
// amount borrowed on the policy less a ADMINFEE on the
// face value.
// your code here, compute the surrender value and replace the
// following line
return (SURRENDER_RATE * faceValue) * (inYrsHeld / policyYrs) - inBorAmt - (faceValue * ADMIN_FEE);
}
/**
* Return a string representation of the WholeLifePolicy.
*
* @return String output string.
*
* <pre>
* Produce output in the following format:
*
* Policy Information:
* Policy #: WLP1000000
* Policy Years: 20
* Face Value: 50000.0
*
* </pre>
*/
public String toString() {
String output = "Policy Information:\n";
output = output + "Policy #: " + this.getPolicyNum() + "\n";
// your code here, finish the output string
output = output + "Policy Years: "+this.getPolicyYrs()+"\n";
output = output + "Face Value: "+this.getFaceValue()+"\n";
return output;
}
}