Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void AmortissementLineaire(BienAmortissable b1)
- {
- Console.WriteLine("Amortissement linéaire en prorata temporis\n\n");
- // Check duree vie
- int duree = b1.DureeVie1;
- double taux = 1 / (double)duree;
- int proataDebut = 360 - ( b1.DateMiseService1.Day - 30 + b1.DateMiseService1.Month * 30 ) ;
- int proataFin = 360 - proataDebut;
- duree = proataDebut == 360 ? duree : duree+=1 ;
- // Var
- double uncDebut = b1.CoutAchat1;
- double uncFin = b1.CoutAchat1;
- double annuite = 0;
- double cumul = 0;
- double valeurAmortissable = b1.CoutAchat1 - b1.ValeurCession1;
- // Each year
- for ( int i = 0; i < duree; i++ )
- {
- // Unique annuite calc for first year, last year
- if ( i == 0)
- {
- // First year
- annuite = valeurAmortissable * taux * proataDebut / 360;
- }
- else
- {
- /* Ternary operator
- * Check is not last year
- * true -> Calc annuite for lambda year
- * false -> Calc annuite for last year
- */
- annuite = i != duree - 1 ? annuite = valeurAmortissable * taux : valeurAmortissable * taux * proataFin / 360;
- // Increment year
- b1.DateMiseService1 = b1.DateMiseService1.AddYears(1);
- }
- cumul += annuite;
- uncFin -= annuite;
- Console.WriteLine("EXERCICE : {0}", b1.DateMiseService1.Year);
- Console.WriteLine("\tUNC début : {0}", uncDebut);
- Console.WriteLine("\tAnnuité : {0}", annuite);
- Console.WriteLine("\tCumul : {0}", cumul);
- Console.WriteLine("\tUNC fin : {0}\n", uncFin);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement