Weewee21

InterestFunctionsWalletYearlyInterestLastInterest

Jan 11th, 2021
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.67 KB | None | 0 0
  1. public static void Main(string[]args)
  2.         {
  3.             double sumofir, sumdanny;
  4.             sumofir = SumIntrest(1000, 6, 36);//מחשב את הכסף שהיה לאופיר אחרי 3 שנים עם 6 אחוזי ריבית
  5.             sumofir = SumIntrest(8147.25, 7, 36);//מחשב את הכסף שהיה לאופיר אחרי עוד 3 שנים עם 7 אחוזי ריבית
  6.             Console.WriteLine("the money that Ofir had after 6 years is: " + sumofir + " Shekels");
  7.             sumdanny = MonthlyIntrest(100,5);//מחשב את הכסף שהיה לדני אחרי 3 שנים עם ריבית של 5 אחוזים והוספה של 100 בכל חודש
  8.             for (int i = 0; i < 35; i++)
  9.             {
  10.                 sumdanny += 100;
  11.                 sumdanny = SumIntrest(sumdanny, 5, 1);
  12.             }
  13.             Console.WriteLine("after 3 years danny had " + sumdanny + " Shekels");
  14.         }
  15.         static double MonthlyIntrest(double money, int intrest)//מחשב ריבית בחודש כשנתון הכסף והאחוזי ריבית
  16.         {
  17.             double afterintrest;
  18.             afterintrest = money + (0.01 *intrest * money);
  19.             return afterintrest;
  20.         }
  21.         static double SumIntrest(double money, int intrest, int months)//מחשב את הריבית בכמה חודשים כשנתון הכסף אחוזי הריבית ומספר החודשים
  22.         {
  23.             double lastintrest;
  24.             lastintrest = MonthlyIntrest(money, intrest);
  25.             for (int i = 1; i < months; i++)
  26.             {
  27.                 lastintrest = MonthlyIntrest(lastintrest, intrest);
  28.             }
  29.             return lastintrest;
  30.         }
Advertisement
Add Comment
Please, Sign In to add comment