Advertisement
Andites

Мат. Методы (лб1)

Sep 6th, 2023 (edited)
116
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.53 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace лб_1
  8. {
  9. class lab1
  10. {
  11. public static double accurate(int n, double perc, double sum, int month, int amountofyears)
  12. {
  13. int k = 365;
  14. int fully = 365;
  15. for (int i = 0; i <= amountofyears; i++)
  16. {
  17. if (month == 12) month = 0;
  18. if (month + 1 <= 7 && month + 1 > 2)
  19. {
  20. for (; month != 12; month++)
  21. {
  22. if (month / 2 == 0)
  23. {
  24. n += 30;
  25. }
  26. else n += 31;
  27. }
  28. }
  29. if (month + 1 > 7)
  30. {
  31. for (; month != 12; month++)
  32. {
  33. if (month / 2 == 0)
  34. {
  35. n += 31;
  36. }
  37. else n += 30;
  38. }
  39. }
  40. if (month + 1 == 2)
  41. {
  42. n += 28;
  43. for (; month != 12; month++)
  44. {
  45. if (month <= 7)
  46. {
  47. if (month / 2 == 0)
  48. {
  49. n += 30;
  50. }
  51. else n += 31;
  52. }
  53. else
  54. {
  55. if (month / 2 == 0)
  56. {
  57. n += 31;
  58. }
  59. else n += 30;
  60. }
  61. }
  62. }
  63. }
  64. Console.WriteLine(n);
  65. double fullperc = sum * n * perc;
  66. //Console.WriteLine(sum + " " + perc);
  67. return fullperc;
  68. }
  69. public static double commacc(int n, double perc, double sum)
  70. {
  71. int k = 360;
  72. n = n * 365;
  73. double fulltime = n / k;
  74. double fullperc = sum * fulltime * perc;
  75. return fullperc;
  76. }
  77. public static double comm(int n, double perc, double sum)
  78. {
  79. int k = 360;
  80. n = n * 360;
  81. double fulltime = n / k;
  82. double fullperc = sum * fulltime * perc;
  83. return fullperc;
  84. }
  85. static void Main()
  86. {
  87. Console.WriteLine("Введите необходимую сумму:");
  88. double sum = Convert.ToDouble(Console.ReadLine());
  89. Console.WriteLine("Введите процентную ставку:");
  90. double perc = Convert.ToDouble(Console.ReadLine());
  91. Console.WriteLine("Введите дату начала:");
  92. string n = Console.ReadLine();
  93. Console.WriteLine("Введите дату конца:");
  94. string n2 = Console.ReadLine();
  95.  
  96. //счет времени
  97. int[] nn = new int[3];
  98. string[] ns = n.Split('.');
  99. for (int i = 0; i < 2; i++)
  100. {
  101.  
  102. nn[i] = Convert.ToInt32(ns[i]);
  103. }
  104. int[] nn2 = new int[3];
  105. string[] nss = n2.Split('.');
  106. for (int i = 0; i < 2; i++)
  107. {
  108. nn2[i] = Convert.ToInt32(nss[i]);
  109. }
  110. int years = nn2[2] - nn[2];
  111. int months;
  112. if (nn2[1] >= nn[1]) months = nn2[1] - nn[1];
  113. else months = (12 - nn[1]) + nn2[1];
  114. int days = 0;
  115. if (nn2[0] >= nn[0]) days = nn2[0] - nn[0];
  116. else if (nn[1] / 2 == 0 && nn[1] != 2 && nn[1] < 8) days = 30 - nn[0] + nn2[0];
  117. else if (nn[1] == 2) days = 28 - nn[0] + nn2[0];
  118. else if (nn[1] / 2 == 0 && nn[1] != 2 && nn[1] >= 8) days = 31 - nn[0] + nn2[0];
  119. else if (nn[1] / 2 != 0 && nn[1] != 2 && nn[1] < 8) days = 31 - nn[0] + nn2[0];
  120. else if (nn[1] / 2 != 0 && nn[1] != 2 && nn[1] >= 8) days = 30 - nn[0] + nn2[0];
  121.  
  122. Console.Clear();
  123. Console.WriteLine("Выберите метод:\n1.Метод точных процентов\n2.Метод обыкновенных процентов\n3.Метод обыкновенных процентов с приближенным числом дней ссуды");
  124. int choice = Convert.ToInt32(Console.ReadLine());
  125. double fullsum = 0;
  126. double I;
  127. switch (choice)
  128. {
  129. case 1:
  130. I = accurate(days, perc, sum, months, years);
  131. fullsum = sum + I;
  132. Console.WriteLine("Сумма к возврату: " + fullsum);
  133. break;
  134. //case 2:
  135. // I = commacc(n, perc, sum);
  136. // fullsum = sum + I;
  137. // Console.WriteLine("Сумма к возврату: " + fullsum);
  138. // break;
  139. //case 3:
  140. // I = comm(n, perc, sum);
  141. // fullsum = sum + I;
  142. // Console.WriteLine("Сумма к возврату: " + fullsum);
  143. // break;
  144. }
  145. Console.ReadKey();
  146. }
  147. }
  148. }
  149.  
Advertisement
Comments
  • Andites
    293 days
    # text 0.18 KB | 0 0
    1. Нужно посчитать полное кол-во дней (для каждого метода будет своим способом, когда-то 30 в каждом месяце)
  • Andites
    293 days
    # text 0.07 KB | 0 0
    1. Для каждого расчета в итоге: кол-во дней - 1
Add Comment
Please, Sign In to add comment
Advertisement