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
Can i please VHDL code for D-Latch with clear input ?? (HINT: Set up a “Process” with appropriate sensitivity list to get the desired D-Latch with Clr working.) Inputs and Outputs: entity Lab4b is Port ( Clr, Clk, D : in STD_LOGIC; Q : out STD_LOGIC); end Lab4b;
what is session state?
what is the difference between read the data from table and infotype
19. Given a system that is described with the following equation, X=A+(B.(A̅+C)+C)+A.B.(D̅+E̅) a) Simplify the equation using Boolean Algebra. b) Implement the original and then the simplified equation with a digital circuit. c) Implement the original and then the simplified equation in ladder logic.
what is difference between input parameter and output parameter.
hi This is radhika.Can anyone help me to know the question papers of NATIONAL INFORMATICS CENTRE for the post of scientific officer/engineer? if anyone know plz tell me question paper pattern
what is technical system, business system, logical system in sap pi7.0
hi all, i need ur help in preparing a sql which performs scd2, i mean i have a scd2 mapping i need a sql which can give me same result as scd2 mapping, SRC table: cust_no, loc 01 abc 02 xyz TGT table: pm_ky cust_no loc current_flag 1 01 abc Y 2 02 xyz Y cust 1 has changed his loc to xyz then it loads into TGT table as below, pm_ky cust_no loc current_flag 1 01 abc N 2 02 xyz Y 3 01 xyz Y i need sql to get the above result, hope got me question, Any suggestion will be appreciate.. thanks, Vinod
EXPLAIN UNARY OPEARATORS
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.
what is class module in vb6? what it's use? with example..
When we delete logfiles such as screenshots how does it affect the ldf file? Ive seen huge change while adding screenshots in the ldf file but a very minor one deleting them.Please Explain
why we need to take u?
how CLR identify vb file?
Is class is a abstract datatype in java?