public void Run()
        {
            Console.WriteLine("WELCOME TO SMARTCAR INSURANCE CALCULATOR.\n" +
                              "Lets use some driver information to calculate an insurance premium.\n" +
                              "First, I will need some driver data. You should already pulled this info from the smartcar's computer.\n" +
                              "If you have the information, and wish to proceed, press enter:\n");
            Console.ReadKey();
            Console.Clear();

            Console.WriteLine("Please enter the driver's SmartCarID #");
            int smartCarID = int.Parse(Console.ReadLine());

            Console.WriteLine("How often did the driver drive over the speed limit (response will be in the form of %, round decimals up to next number):");
            int overSL = int.Parse(Console.ReadLine());

            Console.WriteLine("How often did the driver swerve?");
            int swerve = int.Parse(Console.ReadLine());

            Console.WriteLine("How often did the driver roll through stop signs?");
            int rollSS = int.Parse(Console.ReadLine());

            Console.WriteLine("How often did the driver tailgate other drivers?");
            int tailgate = int.Parse(Console.ReadLine());

            //public DriverData(int smartCarID, int overSL, int swerve, int rollSS, int Talgate)
            DriverData driver = new DriverData(smartCarID, overSL, swerve, rollSS, tailgate);
            //_driver.AddDriverToList(driver);
            decimal totalCost = _driver.TotalPremiumCost(driver);

            Console.Clear();

            Console.WriteLine($"The total insurance premium for this driver based on performance is {totalCost}.");
            Console.WriteLine("Thank you.");
            Console.ReadKey();
        }
示例#2
0
        public decimal TotalPremiumCost(DriverData driver)
        {
            decimal baseCost = 20.0m;

            decimal sLcharge     = CalculateDriverPremiumPartOne(driver);
            decimal swerveStat   = CalculateDriverPremiumPartTwo(driver);
            decimal rollStat     = CalculateDriverPremiumPartThree(driver);
            decimal tailgateStat = CalculateDriverPremiumPartFour(driver);

            decimal totalPremiumCost = sLcharge + swerveStat + rollStat + tailgateStat + baseCost;

            return(totalPremiumCost);
        }
        public decimal DriverInsruance(DriverData driverInfo)
        {
            decimal insurance = 100.00m;

            if (driverInfo.FollowTheLimit >= 100)
            {
                insurance -= 25.00m;
            }
            else if (driverInfo.OverTheLimit >= 100)
            {
                insurance += 100.00m;
            }

            if (driverInfo.FollowTooClose >= 20 && driverInfo.FollowTooClose
                <= 40)
            {
                insurance += 15.00m;
            }
            else if (driverInfo.FollowTooClose >= 41 && driverInfo.FollowTooClose <= 60)
            {
                insurance += 30.00m;
            }
            else if (driverInfo.FollowTooClose >= 61)
            {
                insurance += 60.00m;
            }

            if (driverInfo.RollThroughStop >= 20 && driverInfo.RollThroughStop <= 60)
            {
                insurance += 20.00m;
            }
            else if (driverInfo.RollThroughStop >= 61 && driverInfo.RollThroughStop <= 70)
            {
                insurance += 40.00m;
            }
            else if (driverInfo.RollThroughStop > 71)
            {
                insurance += 80.00m;
            }

            if (driverInfo.StayInLane >= 70)
            {
                insurance -= 30.00m;
            }

            return(insurance);
        }
示例#4
0
        public decimal CalculateDriverPremiumPartThree(DriverData driver)
        {
            decimal rollStat = 0m;

            if (driver.RollSS > 9 && driver.RollSS < 30)
            {
                rollStat = 10m;
            }
            else if (driver.RollSS > 29 && driver.RollSS < 60)
            {
                rollStat = 25m;
            }
            else if (driver.RollSS > 59)
            {
                rollStat = 50m;
            }
            else
            {
                rollStat = 0;
            }

            return(rollStat);
        }
示例#5
0
        public decimal CalculateDriverPremiumPartTwo(DriverData driver)
        {
            decimal swerveStat = 0m;

            if (driver.Swerve > 9 && driver.Swerve < 30)
            {
                swerveStat = 10m;
            }
            else if (driver.Swerve > 29 && driver.Swerve < 60)
            {
                swerveStat = 25m;
            }
            else if (driver.Swerve > 59)
            {
                swerveStat = 50m;
            }
            else
            {
                swerveStat = 0;
            }

            return(swerveStat);
        }
示例#6
0
        public decimal CalculateDriverPremiumPartOne(DriverData driver)
        {
            decimal sLcharge = 0m;

            if (driver.OverSL > 9 && driver.OverSL < 30)
            {
                sLcharge = 10m;
            }
            else if (driver.OverSL > 29 && driver.OverSL < 60)
            {
                sLcharge = 25m;
            }
            else if (driver.OverSL > 59)
            {
                sLcharge = 50m;
            }
            else
            {
                sLcharge = 0;
            }

            return(sLcharge);
        }
示例#7
0
        public decimal CalculateDriverPremiumPartFour(DriverData driver)
        {
            decimal tailgateStat = 0m;

            if (driver.Tailgate > 9 && driver.Tailgate < 30)
            {
                tailgateStat = 10m;
            }
            else if (driver.Tailgate > 29 && driver.Tailgate < 60)
            {
                tailgateStat = 25m;
            }
            else if (driver.Tailgate > 59)
            {
                tailgateStat = 50m;
            }
            else
            {
                tailgateStat = 0;
            }

            return(tailgateStat);
        }
 public void AddDriverToList(DriverData driverInfo)
 {
     _driverData.Add(driverInfo);
 }