Question: Can someone please provide C# code in exception handling for below problem.- -------------------------------------------------- Invalid Agent XYZ Insurance company issues an online customer portal wherein the

Can someone please provide C# code in exception handling for below problem.-

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

Invalid Agent

XYZ Insurance company issues an online customer portal wherein the customer submits a claim request to avail any claim. This portal checks for the following, 1. Policy renewal date must be ahead of the policy start date. 2. Agent id corresponding to the agent must be registered with the company. Write a program to validate the above details and display an error message if it is not in the given format. Create classes InvalidDateException and InvalidAgentException which extends Exception class.

Create Policy class with the following attributes

Data Type Variable Name
string _policyId
string _brokerId
DateTime _policyStartDate
DateTime _policyRenewalDate

Create a 4 argument constructor with the following arguments _policyId, _brokerId, _policyStartDate, _policyRenewalDate Override the ToString() method and return the policy details in the given format( refer sample input and output). Create Agent class with the following attributes

Data Type Variable Name
string _agentId
string _agentName

Create a 2 argument constructor with the following arguments _agentId, _agentName Create PolicyBO class with the following method

Method Description
Policy ValidateData(string _policyDetails, List agentList) This method throws InvalidAgentException if the agent name in policy details is not found in the agent list and throws InvalidDateException if the dates are not valid or if the start date is ahead of the renewal date.

Create Program class to test the above classes. Prepopulate the agent list and get the policy details and call the ValidateData() method. To handle both the exceptions surround the method call with try catch block. Prepopulate the following data in the agent List

Agent ID Agent Name
1201 Abraham
1202 Adam
1203 Albert
1204 Blake

Input and Output Format: The input is policy details as a single string separated by " , ". The order of the input must be policy ID, broker ID, policy start date, policy renewal date. The dates must be in the (dd-mm-yyyy) format. Refer sample input and output for formatting specifications. All text in bold corresponds to input and the rest corresponds to output. Sample Input/Output 1:

LI1001,1208,11-04-2015,11-05-2015

Exception : Agent not found! Sample Input/Output 2:

LI1001,1201,11-4-2015,11-05-2015

Exception : Invalid date! Sample Input/Output 3:

LI1001,1201,11-04-2015,11-05-2015

Policy ID : LI1001

Broker ID : 1201

Policy Start Date : 11-04-2015

Policy Renewal Date : 11-05-2015

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

Thanks

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!