using System.Globalization;
using System.Collections.Generic;
private Dictionary<DateTime, int> kilometers = new Dictionary<DateTime, int> ();
public static void Main()
Console.WriteLine("Please choose car type (type corresponding number): ");
Console.WriteLine("1: Passenger car");
Console.WriteLine("2: Van");
switch (Console.ReadLine())
Console.WriteLine("Invalid input, exiting");
Console.WriteLine("When did your rental start? Example: dd-mm-yyyy");
time = DateTime.Parse(Console.ReadLine(), new CultureInfo("nl-NL"));
} catch (System.FormatException e) {
Console.WriteLine("Could not read date, try again!");
public static CarType PERSONAL = new CarType(50, 100, 0.2);
public static CarType BUS = new CarType(95, 0, 0.3);
private double costPerDay, freeKM, costPerKM;
public CarType(double costPerDay, double freeKM, double costPerKM)
this.costPerDay = costPerDay;
this.costPerKM = costPerKM;
public double GetCostPerDay(double kilometersDriven)
double paidKilometers = kilometersDriven - freeKM;
return paidKilometers * costPerKM + costPerDay;