static void Main(string[] args) { var model = new MonthlyCalculationModel { OldCarPrice = Convert.ToInt32(args[0]), NewCarPrice = Convert.ToInt32(args[1]), SavingPerMonth = Convert.ToInt32(args[2]), PercentLostByMonth = Convert.ToDouble(args[3]) }; var processor = new MonthlyCalculationModelProcessor(); var result = processor.CalculateMonthsToSave(model); Console.WriteLine($"[{result[0]}, {result[1]}]"); }
public int[] CalculateMonthsToSave(MonthlyCalculationModel model) { var remaining = model.NewCarPrice - (model.OldCarPrice + model.TotalSavings); if (remaining <= 0) return new[] {_monthsToSave, -remaining}; CalculateRate(); model.OldCarPrice = ProcessDepreciation(model.OldCarPrice); model.NewCarPrice = ProcessDepreciation(model.NewCarPrice); model.TotalSavings += model.SavingPerMonth; _monthsToSave++; return CalculateMonthsToSave(model); }