Question

In: Computer Science

Can you please tell me if this code needs to be fixed, if it does can...

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;
}

}

Solutions

Expert Solution

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;

    }

}


Related Solutions

Can you please tell me if this code needs to be fixed, if it does can...
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);...
I was wondering if you can tell me if the following code is correct and if...
I was wondering if you can tell me if the following code is correct and if its not can it be fixed so it does not have any syntax errors. Client one /** * Maintains information on an insurance client. * * @author Doyt Perry/<add your name here> * @version Fall 2019 */ public class Client { // instance variables private String lastName; private String firstName; private int age; private int height; private int weight; /** * First constructor for...
Can you please tell me why my code isn't working? It won't calculate the values I...
Can you please tell me why my code isn't working? It won't calculate the values I have using my input file. /******************************************************************************* AUTHOR SECTION ENGR 200.07 DATE: 10/23/2020 PROGRAM: ******************************************************************************** PROGRAM DESCRIPTION This program takes a pre-made .txt file’s input values, and calculates the kinetic energy wind farms produce from moving air into electrical energy. Using 3 different formulas this program calculates the available power in the wind, the maximum available power that can be produced, and the amount of...
I need to fix this code, and could you please tell me what was the problem...
I need to fix this code, and could you please tell me what was the problem options 1 and 9 don't work #include <stdio.h> #include <time.h> #include <stdlib.h> // generate a random integer between lower and upper values int GenerateRandomInt(int lower, int upper){     int num =(rand()% (upper - lower+1))+lower;     return num; } // use random numbers to set the values of the matrix void InitializeMatrix(int row, int column, int dimension, int mat[][dimension]){     for(int i =0; i<row; i++){...
please show me or tell me a trick, on how can i tell right away when...
please show me or tell me a trick, on how can i tell right away when a characteristics equation(system) is 1)overdamped 2)underdamped 3)critically damped 4) nonlinear show each an example write neatly!!!!!
Okay, can someone please tell me what I am doing wrong?? I will show the code...
Okay, can someone please tell me what I am doing wrong?? I will show the code I submitted for the assignment. However, according to my instructor I did it incorrectly but I am not understanding why. I will show the instructor's comment after providing my original code for the assignment. Thank you in advance. * * * * * HourlyTest Class * * * * * import java.util.Scanner; public class HourlyTest {    public static void main(String[] args)     {        ...
can you please look at the following code and fix it for me so that it...
can you please look at the following code and fix it for me so that it does not have any syntax errors. also can you tell me what was fixed /** * Driver program to demonstrate calling methods of Client class. * * @author Doyt Perry/Tina Comston * @version Fall 2019 */ public class ClientDemo { public static void main() { /** * main method - makes this an executable program. */ // create a client with placeholder values System.out.println("Client...
Can you tell me what is wrong with this code ? def update_char_view(phrase: str, current_view: str,...
Can you tell me what is wrong with this code ? def update_char_view(phrase: str, current_view: str, index: int, guess: str)->str: if guess in phrase: current_view = current_view.replace(current_view[index], guess) else: current_view = current_view    return current_view update_char_view("animal", "a^imal" , 1, "n") 'animal' update_char_view("animal", "a^m^l", 3, "a") 'aamal'
how does steve (owner of apple) made the decisions ? after that can you tell me...
how does steve (owner of apple) made the decisions ? after that can you tell me your own thoughts about it if you agree or not? thank you how does steve ;( owner of apple )makes the decisions in the company ?
Can someone look into my code and tell me what do you think: Thats Palindrome; //class...
Can someone look into my code and tell me what do you think: Thats Palindrome; //class name Palindrome public class Palindrome {    public static void palindromeChecker(String... str) {        // takes string one by one        for (String s : str) {            // creates a stringbuilder for s            StringBuilder sb = new StringBuilder(s);            // reverses the sb            sb.reverse();            // checks if both...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT