Return the total rent_value when vehicle_no, rented_date, return_date, with_driver parameters are sent in. with_driver parameter is set to true or false depending whether the vehicle is rented with or without driver.
using System;
using System.Collections.Generic;
namespace App
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Total Rent Value: {0}", calculateTotalRentValue("4564235",DateTime.Now,DateTime.Now.AddDays(5),true).ToString("N2"));
Console.ReadLine();
}
/// <summary>
/// Return the total rent_value when vehicle_no, rented_date, return_date,
/// with_driver parameters are sent in. with_driver parameter is set to true
/// or false depending whether the vehicle is rented with or without driver.
/// </summary>
/// <param name="vehicle_no"></param>
/// <param name="rented_date"></param>
/// <param name="return_date"></param>
/// <param name="with_driver"></param>
/// <returns></returns>
static double calculateTotalRentValue(string vehicle_no, DateTime rented_date, DateTime return_date, bool with_driver)
{
double tota_rent_value = (return_date - rented_date).TotalDays*100.0;
if (with_driver) {
tota_rent_value += 25;
}
return tota_rent_value;
}
}
}
Comments
Leave a comment