Answer to Question #252617 in C# for Nik duminda

Question #252617

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.



1
Expert's answer
2021-10-17T09:29:45-0400
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;
        } 
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS