Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. The DriveRite Insurance Company provides automobile insurance policies for dr

ID: 3864696 • Letter: 2

Question

2. The DriveRite Insurance Company provides automobile insurance policies for drivers. Design a single class diagram showing the class, the application program, the relationship between the two, and multiplicity. Insert the completed class diagram into a Word document. Then write the pseudocode as described below. Be sure to follow the CSI 117 Style Criteria for naming conventions, class diagrams, pseudocode, keywords, and operators.
a. Create a PolicyHolder class that contains a policy number, customer age, and the number of accidents in which the driver has been involved in the last three years. Include the following: i. A default constructor that initializes each attribute to some reasonable default value for a non-existent policy holder. ii. Another constructor method that has a parameter for each data member, called the overloaded constructor. This constructor initializes each attribute to the value provided when an object of this type is instantiated. If the customer's age is not between 14 and 125 inclusive, then display an error message and set the age to 0. iii. Accessor and mutator methods for each attribute. For the age mutator, if the customer's age is not between 14 and 125 inclusive, then set the age to 0, since this is obviously an error. iv. A method that displays all the data about a policy holder.

b. An application program that contains two modules: the main() module and the checkAccident() module. Include instructions in the main() module to do the following: i. Create and initialize a PolicyHolder object using the default constructor, naming it newPolicyHolder. Call the appropriate methods to initialize all the data members for the newPolicyHolder object, choosing appropriate values. ii. Create and initialize 2 different PolicyHolder objects using the overloaded constructor. Choose appropriate values for the attributes for each of the two PolicyHolder objects. iii. Call the checkAccident() method for each PolicyHolder object, so there will be 3 calls to the checkAccident() method. The checkAccident() module must do the following: i. Accept a PolicyHolder argument (i.e., it has a parameter declared using PolicyHolder as the data type). ii. Display all the data for any policy holder that is over 35 years old and has one accident or less. 2. The DriveRite Insurance Company provides automobile insurance policies for drivers. Design a single class diagram showing the class, the application program, the relationship between the two, and multiplicity. Insert the completed class diagram into a Word document. Then write the pseudocode as described below. Be sure to follow the CSI 117 Style Criteria for naming conventions, class diagrams, pseudocode, keywords, and operators.
a. Create a PolicyHolder class that contains a policy number, customer age, and the number of accidents in which the driver has been involved in the last three years. Include the following: i. A default constructor that initializes each attribute to some reasonable default value for a non-existent policy holder. ii. Another constructor method that has a parameter for each data member, called the overloaded constructor. This constructor initializes each attribute to the value provided when an object of this type is instantiated. If the customer's age is not between 14 and 125 inclusive, then display an error message and set the age to 0. iii. Accessor and mutator methods for each attribute. For the age mutator, if the customer's age is not between 14 and 125 inclusive, then set the age to 0, since this is obviously an error. iv. A method that displays all the data about a policy holder.

b. An application program that contains two modules: the main() module and the checkAccident() module. Include instructions in the main() module to do the following: i. Create and initialize a PolicyHolder object using the default constructor, naming it newPolicyHolder. Call the appropriate methods to initialize all the data members for the newPolicyHolder object, choosing appropriate values. ii. Create and initialize 2 different PolicyHolder objects using the overloaded constructor. Choose appropriate values for the attributes for each of the two PolicyHolder objects. iii. Call the checkAccident() method for each PolicyHolder object, so there will be 3 calls to the checkAccident() method. The checkAccident() module must do the following: i. Accept a PolicyHolder argument (i.e., it has a parameter declared using PolicyHolder as the data type). ii. Display all the data for any policy holder that is over 35 years old and has one accident or less. 2. The DriveRite Insurance Company provides automobile insurance policies for drivers. Design a single class diagram showing the class, the application program, the relationship between the two, and multiplicity. Insert the completed class diagram into a Word document. Then write the pseudocode as described below. Be sure to follow the CSI 117 Style Criteria for naming conventions, class diagrams, pseudocode, keywords, and operators.
a. Create a PolicyHolder class that contains a policy number, customer age, and the number of accidents in which the driver has been involved in the last three years. Include the following: i. A default constructor that initializes each attribute to some reasonable default value for a non-existent policy holder. ii. Another constructor method that has a parameter for each data member, called the overloaded constructor. This constructor initializes each attribute to the value provided when an object of this type is instantiated. If the customer's age is not between 14 and 125 inclusive, then display an error message and set the age to 0. iii. Accessor and mutator methods for each attribute. For the age mutator, if the customer's age is not between 14 and 125 inclusive, then set the age to 0, since this is obviously an error. iv. A method that displays all the data about a policy holder.

b. An application program that contains two modules: the main() module and the checkAccident() module. Include instructions in the main() module to do the following: i. Create and initialize a PolicyHolder object using the default constructor, naming it newPolicyHolder. Call the appropriate methods to initialize all the data members for the newPolicyHolder object, choosing appropriate values. ii. Create and initialize 2 different PolicyHolder objects using the overloaded constructor. Choose appropriate values for the attributes for each of the two PolicyHolder objects. iii. Call the checkAccident() method for each PolicyHolder object, so there will be 3 calls to the checkAccident() method. The checkAccident() module must do the following: i. Accept a PolicyHolder argument (i.e., it has a parameter declared using PolicyHolder as the data type). ii. Display all the data for any policy holder that is over 35 years old and has one accident or less.

Explanation / Answer

PolicyHolder.java

import java.util.Random;

public class PolicyHolder {
   private int policy_Number;
   private int customer_Age;
   private int number_Of_Accidents;

   public PolicyHolder(int policy_Number, int customer_Age,
           int number_Of_Accidents) {
       super();
       this.policy_Number = policy_Number;
       this.number_Of_Accidents = number_Of_Accidents;
       if (customer_Age >= 14 && customer_Age <= 125)
           this.customer_Age = customer_Age;
       else
           this.customer_Age = 0;
   }

   public PolicyHolder() {
       super();
       this.number_Of_Accidents = 0;
       Random randomGenerator = new Random();
       this.policy_Number = randomGenerator.nextInt(100);
   }

   public int getPolicy_Number() {
       return policy_Number;
   }

   public void setPolicy_Number(int policy_Number) {
       this.policy_Number = policy_Number;
   }

   public int getCustomer_Age() {
       return customer_Age;
   }

   public void setCustomer_Age(int customer_Age) {
       if (customer_Age >= 14 && customer_Age <= 125)
           this.customer_Age = customer_Age;
       else
           this.customer_Age = 0;
   }

   @Override
   public String toString() {
       return "PolicyHolder [policy_Number=" + policy_Number
               + ", customer_Age=" + customer_Age + ", number_Of_Accidents="
               + number_Of_Accidents + "]";
   }

   public int getNumber_Of_Accidents() {
       return number_Of_Accidents;
   }

   public void setNumber_Of_Accidents(int number_Of_Accidents) {
       this.number_Of_Accidents = number_Of_Accidents;
   }

}

----------------------------------------------------------------------

TestPolicyHolder.java

public class TestPolicyHolder {

   public static void main(String[] args) {
       PolicyHolder newPolicyHolder = new PolicyHolder();
       PolicyHolder policyHolder1 = new PolicyHolder(123, 38, 1);
       PolicyHolder policyHolder2 = new PolicyHolder(234, 29, 3);
       checkAccident(newPolicyHolder);
       checkAccident(policyHolder1);
       checkAccident(policyHolder2);
   }

   public static void checkAccident(PolicyHolder policyHolder) {
       if (policyHolder.getCustomer_Age() > 35 && policyHolder.getNumber_Of_Accidents() <= 1){
           System.out.println(policyHolder.toString());
       }
   }

}

output :

PolicyHolder [policy_Number=123, customer_Age=38, number_Of_Accidents=1]

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote