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
/**
* Driver to demonstrate WholeLifePolicy class.
*
* @author Tina Comston
* @version Fall 2019
*/
public class WholeLifePolicyDriver
{
/**
* Creates WholeLifePolicy object, calls methods, displays
values.
*
*/
public static void main()
{
WholeLifePolicyDriver myDriver = new WholeLifePolicyDriver();
// create a policy
WholeLifePolicy policy = new WholeLifePolicy("WLP1234567",
50000, 20);
// display values
myDriver.displayPolicy(policy);
// now change some values
policy.setPolicyNum("WLP9871235");
policy.setFaceValue(75000);
policy.setPolicyYrs(15);
// display again
myDriver.displayPolicy(policy);
// Display termination value at 10 years, borrowed $25K
System.out.printf("Termination value @10 years 25K borrowed "
+
"is %.2f \n", policy.surrenderVal(10.0, 25000));
}
/**
* Displays data for a policy.
*
*/
private void displayPolicy(WholeLifePolicy wlp)
{
System.out.println("*******************************************");
System.out.println(wlp.toString());
System.out.println();
}
}
public class WholeLifePolicyDriver
{
/**
* Creates WholeLifePolicy object, calls methods, displays values.
*
*/
public static void main(String args[])//tou forgot String args[]
{
WholeLifePolicyDriver myDriver = new WholeLifePolicyDriver();
// create a policy
WholeLifePolicy policy = new WholeLifePolicy("WLP1234567",
50000, 20);
// display values
myDriver.displayPolicy(policy);
// now change some values
policy.setPolicyNum("WLP9871235");
policy.setFaceValue(75000);
policy.setPolicyYrs(15);
// display again
myDriver.displayPolicy(policy);
// Display termination value at 10 years, borrowed $25K
System.out.printf("Termination value @10 years 25K borrowed " +
"is %.2f \n", policy.surrenderVal(10.0, 25000));
}
/**
* Displays data for a policy.
*
*/
private void displayPolicy(WholeLifePolicy wlp)
{
System.out.println("*******************************************");
System.out.println(wlp.toString());
System.out.println();
}
}
///////////assuming below is the WholeLife Policy class
class WholeLifePolicy
{
String PolicyNum;
int FaceValue;
int PolicyYrs;
WholeLifePolicy(String PolicyNum,int FaceValue,int PolicyYrs)
{
this.PolicyNum=PolicyNum;
this.FaceValue=FaceValue;
this.PolicyYrs=PolicyYrs;
}
void setPolicyNum(String PolicyNum)
{this.PolicyNum=PolicyNum;}
void setFaceValue(int FaceValue)
{this.FaceValue=FaceValue;}
void setPolicyYrs(int PolicyYrs)
{this.PolicyYrs=PolicyYrs;}
public String toString()
{return "PolicyNum:"+PolicyNum+" FaceValue:"+FaceValue+" PolicyYrs:"+PolicyYrs;}
double surrenderVal(double yr,double amt)
{
return FaceValue*PolicyYrs-yr*amt;
}
}