Building Quotation engine program

Answer Posted / testndl002

BusinessLayer --> QuoteEngine.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TravelInsuranceQuote.DataLayer;

namespace TravelInsuranceQuote.BusinessLayer
{
public class QuoteEngine
{

public double GetBasePremium(TripType tripType)
{
double basePremium = 0;
switch (tripType)
{
case TripType.Single:
basePremium = 20.00;
break;
case TripType.Annual:
basePremium = 80.00;
break;
}
return basePremium;
}

public double GetAgeRating(int age)
{
if (age <= 18)
{
return 1.2;
}
else if (age <= 45)
{
return 1.0;
}
else if (age <= 55)
{
return 1.2;
}
else if (age <= 65)
{
return 1.8;
}
else if (age <= 70)
{
return 2.0;
}
return 0;
}

public double GetSexRating(Sex sex)
{
double sexRating = 0;
switch (sex)
{
case Sex.Male:
sexRating = 1.2;
break;
case Sex.Female:
sexRating = 0.9;
break;
}
return sexRating;
}

public double GetDestinationRating(Destination destination)
{
double destinationRating = 0;
switch (destination)
{
case Destination.UK:
destinationRating = 0.6;
break;
case Destination.Europe:
destinationRating = 1.0;
break;
case Destination.Worldwide:
destinationRating = 1.4;
break;
}
return destinationRating;
}



public double GetTravelPeriodRating(int days)
{
if (days <= 7)
{
return 0.5;
}
else if (days <= 14)
{
return 0.9;
}
else if (days <= 30)
{
return 1.2;
}
return 0;
}

public double[] GetUpdatedPremium(double premium, double rate)
{
var updatedPremium = new double[2];
updatedPremium[0] = Math.Round((premium * rate), 2);
updatedPremium[1] = Math.Round((updatedPremium[0] - premium), 2);
return updatedPremium;
}

public CustomerPremium GetPremium(Customer customer, out string reason)
{
var customerPremium = new CustomerPremium();
customerPremium.Base = GetBasePremium(customer.TripType);
var ageRating = GetAgeRating(customer.Age);
if (ageRating == 0)
{
reason = "Age";
return null;
}
customerPremium.Age = GetUpdatedPremium(customerPremium.Base, ageRating);
var sexRating = GetSexRating(customer.Sex);
customerPremium.Sex = GetUpdatedPremium(customerPremium.Age[0], sexRating);
var destinationRating = GetDestinationRating(customer.Destination);
customerPremium.Destination = GetUpdatedPremium(customerPremium.Sex[0], destinationRating);
var travelPeriodRating = GetTravelPeriodRating(customer.TravelPeriod);
if (travelPeriodRating == 0)
{
reason = "TravelPeriod";
return null;
}
customerPremium.TravelPeriod = GetUpdatedPremium(customerPremium.Destination[0], travelPeriodRating);
customerPremium.Tax = GetUpdatedPremium(customerPremium.TravelPeriod[0], 1.05);
customerPremium.Total = customerPremium.Tax[0];
reason = string.Empty;
return customerPremium;
}

}
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

why we use mantis? what u mean mantis in IT trends? addvantages of mantis?

1741


ok how would i do the following extract from a file i have ssns = 267907230 which are in column 7 into a separate data set then create a 2nd job step to extract from the data set created the following "fund code" which is in column 31 and is 113 into yet another data set

1561


is it possible to desable particular parameter of the normal orcle report based on some condition ?????? if yes,wht is the function for desabling a parameter...

1582


what is web service in java? have u use before.

1635


it is a language or tools?

1621






when a query is made on Logical file in DB2/400, will the records satisfying select/omit criterion be fetched from all members of physical file or only the member with same name as physical file?

1721


Please describe an example where you used object orientation in one of your programs.

1492


Which method protects back button to retrieve old value from previous page in Struts.

1454


Write a shell program to test whether a given year is leap year or not ?

2264


Definition of Singleton Class? what is the Purpose of it? what is the advantage?

1591


What is test execution and when will we start execution please send me one example for this question

1430


Do not use more than 3 nested IF. Use Evaluate statement in case of more IF required. Please give a detail explantion besides readability and clarity for Evaluate stmt.

1485


How to set on/off a group of indicators in a single statement?

1380


Explain the difference between an expert and a novice user. How would your strategy for designing user interfaces for an expert user differ from that for designing user interfaces for a novice user.

2614


what is the purpose of checked Menu options

1986