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

The DriveRite Insurance Company provides automobile insurance policies for drive

ID: 3861544 • Letter: T

Question

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.

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:

Accept a PolicyHolder argument (i.e., it has a parameter declared using PolicyHolder as the data type).

Display all the data for any policy holder that is over 35 years old and has one accident or less.

Explanation / Answer


public class PolicyHolder
{
  
int age,no_ac;
String policyNo;
double bonus;

public void setPolicyNum(String no)
{
policyNo= no;
}
public String getPolicyNum()
{
return policyNo;
}
public void setCustomerAge(int age)
{
this.age= age;
}
public int getCustomerAge()
{
return age;
}
public void setNumAccidents(int no_ac)
{
this.no_ac= no_ac;
}
public int getNumAccidents()
{
return no_ac;
}
public void display()
{
System.out.println("Policy no : "+policyNo);
System.out.println("age : "+age);
System.out.println("No of accident : "+no_ac);
}
//Data Members
public PolicyHolder()
{
setPolicyNum("1234");
setCustomerAge(42);
setNumAccidents(1);

  
}
public PolicyHolder(String no, int age,int no_ac)
{
setPolicyNum(no);
setCustomerAge(age);
setNumAccidents(no_ac);
}
public void checkAccident(PolicyHolder obj)
{
int age,no_of_accident;
age=obj.getCustomerAge();
no_of_accident=obj.getNumAccidents();

//Verify that age is greater than 35, and accidents are less than 1
if(age>35 && no_of_accident<=1)
{
display();
}
  
}

public static void main(String args[])
{
PolicyHolder newPolicyHolder, newPolicyHolder2, newPolicyHolder3;
newPolicyHolder =new PolicyHolder();
newPolicyHolder.checkAccident(newPolicyHolder);


newPolicyHolder2 =new PolicyHolder("A21", 45, 1);
newPolicyHolder2.checkAccident(newPolicyHolder2);
  
newPolicyHolder3 =new PolicyHolder("A52", 52, 1);
newPolicyHolder3.checkAccident(newPolicyHolder3);
}
}
  

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