Building Quotation engine program

Answer Posted / testndl002

PresentationLayer --> Program.cs


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

namespace TravelInsuranceQuote.PresentationLayer
{
public class Program
{

public static void Main(string[] args)
{
var customer = new Customer();

string[] lines = File.ReadAllLines(@"D:\Test.txt");

foreach (var line in lines)
{
var nameValue = line.Split(new char[] { ':' });
switch (nameValue[0].ToLower())
{
case "triptype":
customer.TripType = ((nameValue[1].ToLower() == "single") ? TripType.Single : TripType.Annual);
break;
case "sex":
customer.Sex = ((nameValue[1].ToLower() == "male") ? Sex.Male : Sex.Female);
break;
case "destination":
customer.Destination = ((nameValue[1].ToLower() == "uk") ? Destination.UK :
((nameValue[1].ToLower() == "europe") ? Destination.Europe : Destination.Worldwide));
break;
case "age":
customer.Age = Convert.ToInt32(nameValue[1]);
break;
case "travelperiod":
customer.TravelPeriod = Convert.ToInt32(nameValue[1]);
break;
}

}

//Console.Write("Type:");
//customer.TripType = ((Console.ReadLine().ToLower() == "single") ? TripType.Single : TripType.Annual);
//Console.Write("Age:");
//customer.Age = int.Parse(Console.ReadLine());
//Console.Write("Sex:");
//customer.Sex = ((Console.ReadLine().ToLower() == "male") ? Sex.Male : Sex.Female); ;
//Console.Write("Destination:");
//switch(Console.ReadLine().ToLower())
//{
// case "uk" :
// customer.Destination = Destination.UK;
// break;
// case "europe" :
// customer.Destination = Destination.Europe;
// break;
// case "worldwide" :
// customer.Destination = Destination.Worldwide;
// break;
//}
//Console.Write("TravelPeriod:");
//customer.TravelPeriod = int.Parse(Console.ReadLine());

string reason;
var customerPremium = new QuoteEngine().GetPremium(customer, out reason);

if (customerPremium != null)
{
Console.WriteLine("BasePremium({0}):{1}", customerPremium.Base, customerPremium.Base);
Console.WriteLine("Age({0}):{1}", customerPremium.Age[1], customerPremium.Age[0]);
Console.WriteLine("Sex({0}):{1}", customerPremium.Sex[1], customerPremium.Sex[0]);
Console.WriteLine("Destination({0}):{1}", customerPremium.Destination[1], customerPremium.Destination[0]);
Console.WriteLine("TravelPeriod({0}):{1}", customerPremium.TravelPeriod[1], customerPremium.TravelPeriod[0]);
Console.WriteLine("Tax({0}):{1}", customerPremium.Tax[1], customerPremium.Tax[0]);
Console.WriteLine("Total:{0}", customerPremium.Total);
}
else
{
Console.Write("Declined:" + reason);
}
Console.ReadKey();
}
}
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How does the type system works when there is interoperability between a COM and .Net, i mean what exactly happens there

1567


V2 SOLUTIONS APTI paper is very easy there are 3 sections 1'st is quant problem on age train traveling speed is given length of train is given we have to find out length of bridge then prob on calender one date is given on Friday hv to find out day of othe date ans is Friday then there was 1 prob on percentage which was very easy ans was 21340 then 2’nd section was english grammer had has been being like that hv to fill in the blanks was very wasy then last section was find relative words there was five Q 1 pant ANS:-breath 2inquire ans :- ask And 3 more out of that 1 ‘s ans was:- body 4 And others ans was :-through THEN THEY HAVE GD There was three topics 1 should we allow india’s talent to go to abrod 2 protest against seperate state is justify 3 inturuption of politics in cricket Thats all guys i cleared both the rounds now preparing 4 interview best of luck

1778


How to merge Action Form with Dyna Action Form in Struts.

1896


How to use string functions in QTP?give some examples

7119


Differevce between arrays and array builders?

1648






Write a program to find whether a given number is prime or not.

611


what is the similarity between networking devices?

1678


How can we develop a multi-tier application in Java?

1472


Given an array of size n. It contains numbers in the range 1 to n. Each number is present at least once except for 1 number. Find the missing number

729


how will you code the subfile which is in editing mode (multiple case subfile)?

1603


what are the topics choosen for jam round for interviews

1162


WHat is execution in manual testing and when will we start execution and what language we use in execution

1481


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


Q2. A memory location has physical address D5687h. Compute: a. The offset address if the segment number is D445h. b. The segment number if the offset address is B577h.

1632


Define distributed queries. can you explain me as soon as possible

1627