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

/**
* 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();
}
}

Solutions

Expert Solution

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;

}

}


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 /** * 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; /**...
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