О проекте

  1. <!DOCTYPE html>
  2. <html lang="ru">
  3. <meta charset="UTF-8">
  4. <title>Калькулятор кормления и роста КРС</title>
  5. body { font-family: Arial, sans-serif; max-width: 900px; margin: 20px auto; }
  6. label { display: block; margin: 8px 0 4px; }
  7. input, select, button { padding: 6px; font-size: 16px; }
  8. table { border-collapse: collapse; margin-top: 15px; width: 100%; }
  9. th, td { border: 1px solid #ccc; padding: 6px; text-align: center; }
  10. th { background: #f5f5f5; }
  11. h2, h3 { margin-top: 25px; }
  12. button { margin-top: 10px; cursor: pointer; }
  13. </style>
  14. </head>
  15.  
  16. <h2>Калькулятор кормления и роста КРС (1&ndash;480 дней)</h2>
  17.  
  18. <label>Тип животного:</label>
  19. <select id="animalType">
  20. <option value="bull">Бык</option>
  21. <option value="cow">Корова</option>
  22.  
  23. <label>День жизни (1&ndash;480):</label>
  24. <input type="number" id="day" min="1" max="480" value="1">
  25.  
  26. <button onclick="calculate()">Рассчитать</button>
  27.  
  28. <h3>Результаты</h3>
  29. <div id="resultWeight" style="font-size:18px; font-weight:bold;"></div>
  30.  
  31. <tr>
  32. <th>Ресурс</th>
  33. <th>Потребление, кг/сутки</th>
  34. </tr>
  35. </thead>
  36. <tbody id="feedsTable"></tbody>
  37.  
  38. function calculate() {
  39. const type = document.getElementById('animalType').value;
  40. const day = parseInt(document.getElementById('day').value, 10);
  41.  
  42. if (isNaN(day) || day < 1 || day > 480) {
  43. alert('Введите день от 1 до 480');
  44. return;
  45. }
  46.  
  47. // --- ВЕС ---
  48. let weight = 0;
  49.  
  50. const w60_bull = 16;
  51. const w60_cow = 13;
  52.  
  53. const w240_bull = w60_bull + 1.583 * (240 - 60);
  54. const w240_cow = w60_cow + 1.083 * (240 - 60);
  55.  
  56. if (day <= 60) {
  57. weight = (type === 'bull')
  58. ? 0.5 + 0.263 * (day - 1)
  59. : 0.5 + 0.212 * (day - 1);
  60. } else if (day <= 240) {
  61. weight = (type === 'bull')
  62. ? w60_bull + 1.583 * (day - 60)
  63. : w60_cow + 1.083 * (day - 60);
  64. } else if (day <= 420) {
  65. weight = (type === 'bull')
  66. ? w240_bull + 0.4 * (day - 240)
  67. : w240_cow + 0.275 * (day - 240);
  68. } else {
  69. const w420_bull = w240_bull + 0.4 * (420 - 240);
  70. const w420_cow = w240_cow + 0.275 * (420 - 240);
  71. weight = (type === 'bull') ? w420_bull : w420_cow;
  72. }
  73.  
  74. document.getElementById('resultWeight').innerText =
  75. 'Примерный вес: ' + weight.toFixed(2) + ' кг';
  76.  
  77. // --- КОРМА ---
  78. const maxYoung = {
  79. milk: 8, feed: 10, lucerne: 6, turneps: 6,
  80. beet: 3, rutabaga: 3, oats: 3
  81. };
  82.  
  83. const adult1_bull = { feed: 45, lucerne: 4, turneps: 4, beet: 2, rutabaga: 2, oats: 2 };
  84. const adult1_cow = { feed: 35, lucerne: 4, turneps: 4, beet: 2, rutabaga: 2, oats: 2 };
  85.  
  86. const adult2_bull = { feed: 40, lucerne: 3, turneps: 3, beet: 2, rutabaga: 2, oats: 2 };
  87. const adult2_cow = { feed: 30, lucerne: 3, turneps: 3, beet: 1.5, rutabaga: 1.5, oats: 1.5 };
  88.  
  89. const oldMax = { feed: 30, lucerne: 3, turneps: 3, beet: 2, rutabaga: 2, oats: 2 };
  90.  
  91. let feeds = {};
  92.  
  93. if (day <= 60) {
  94. const k = (day - 1) / 59;
  95. feeds.milk = 0.1 + (maxYoung.milk - 0.1) * k;
  96. feeds.feed = 0.1 + (maxYoung.feed - 0.1) * k;
  97. feeds.lucerne = 0.1 + (maxYoung.lucerne - 0.1) * k;
  98. feeds.turneps = 0.1 + (maxYoung.turneps - 0.1) * k;
  99. feeds.beet = 0.1 + (maxYoung.beet - 0.1) * k;
  100. feeds.rutabaga = 0.1 + (maxYoung.rutabaga - 0.1) * k;
  101. feeds.oats = 0.1 + (maxYoung.oats - 0.1) * k;
  102. } else if (day <= 240) {
  103. const base = (type === 'bull') ? adult1_bull : adult1_cow;
  104. feeds = { milk: 0, ...base };
  105. } else if (day <= 420) {
  106. const base = (type === 'bull') ? adult2_bull : adult2_cow;
  107. feeds = { milk: 0, ...base };
  108. } else {
  109. const k = (480 - day) / 59;
  110. feeds.milk = 0;
  111. feeds.feed = 0.1 + (oldMax.feed - 0.1) * k;
  112. feeds.lucerne = 0.1 + (oldMax.lucerne - 0.1) * k;
  113. feeds.turneps = 0.1 + (oldMax.turneps - 0.1) * k;
  114. feeds.beet = 0.1 + (oldMax.beet - 0.1) * k;
  115. feeds.rutabaga = 0.1 + (oldMax.rutabaga - 0.1) * k;
  116. feeds.oats = 0.1 + (oldMax.oats - 0.1) * k;
  117. }
  118.  
  119. const tbody = document.getElementById('feedsTable');
  120. tbody.innerHTML = '';
  121.  
  122. const names = {
  123. milk: 'Молоко',
  124. feed: 'Комбикорм',
  125. lucerne: 'Люцерна',
  126. turneps: 'Турнепс',
  127. beet: 'Кормовая свекла',
  128. rutabaga: 'Брюква',
  129. oats: 'Овес'
  130. };
  131.  
  132. for (let key in names) {
  133. const tr = document.createElement('tr');
  134. tr.innerHTML = `<td>${names[key]}</td><td>${feeds[key].toFixed(2)}</td>`;
  135. tbody.appendChild(tr);
  136. }
  137. }
  138.  
  139. </body>
  140. </html>
  141.  
Посещая этот сайт, вы соглашаетесь с тем, что мы используем файлы cookie.