<!DOCTYPE html>
body { font-family: Arial, sans-serif; max-width: 900px; margin: 20px auto; }
label { display: block; margin: 8px 0 4px; }
input, select, button { padding: 6px; font-size: 16px; }
table { border-collapse: collapse; margin-top: 15px; width: 100%; }
th, td { border: 1px solid #ccc; padding: 6px; text-align: center; }
th { background: #f5f5f5; }
h2, h3 { margin-top: 25px; }
button { margin-top: 10px; cursor: pointer; }
<h2>Калькулятор кормления и роста КРС (1
–480 дней)
</h2>
<input type="number" id="day" min="1" max="480" value="1">
<div id="resultWeight" style="font-size:18px; font-weight:bold;"></div>
<th>Потребление, кг/сутки
</th>
function calculate() {
const type = document.getElementById('animalType').value;
const day = parseInt(document.getElementById('day').value, 10);
if (isNaN(day) || day < 1 || day > 480) {
alert('Введите день от 1 до 480');
return;
}
// --- ВЕС ---
let weight = 0;
const w60_bull = 16;
const w60_cow = 13;
const w240_bull = w60_bull + 1.583 * (240 - 60);
const w240_cow = w60_cow + 1.083 * (240 - 60);
if (day <= 60) {
weight = (type === 'bull')
? 0.5 + 0.263 * (day - 1)
: 0.5 + 0.212 * (day - 1);
} else if (day <= 240) {
weight = (type === 'bull')
? w60_bull + 1.583 * (day - 60)
: w60_cow + 1.083 * (day - 60);
} else if (day <= 420) {
weight = (type === 'bull')
? w240_bull + 0.4 * (day - 240)
: w240_cow + 0.275 * (day - 240);
} else {
const w420_bull = w240_bull + 0.4 * (420 - 240);
const w420_cow = w240_cow + 0.275 * (420 - 240);
weight = (type === 'bull') ? w420_bull : w420_cow;
}
document.getElementById('resultWeight').innerText =
'Примерный вес: ' + weight.toFixed(2) + ' кг';
// --- КОРМА ---
const maxYoung = {
milk: 8, feed: 10, lucerne: 6, turneps: 6,
beet: 3, rutabaga: 3, oats: 3
};
const adult1_bull = { feed: 45, lucerne: 4, turneps: 4, beet: 2, rutabaga: 2, oats: 2 };
const adult1_cow = { feed: 35, lucerne: 4, turneps: 4, beet: 2, rutabaga: 2, oats: 2 };
const adult2_bull = { feed: 40, lucerne: 3, turneps: 3, beet: 2, rutabaga: 2, oats: 2 };
const adult2_cow = { feed: 30, lucerne: 3, turneps: 3, beet: 1.5, rutabaga: 1.5, oats: 1.5 };
const oldMax = { feed: 30, lucerne: 3, turneps: 3, beet: 2, rutabaga: 2, oats: 2 };
let feeds = {};
if (day <= 60) {
const k = (day - 1) / 59;
feeds.milk = 0.1 + (maxYoung.milk - 0.1) * k;
feeds.feed = 0.1 + (maxYoung.feed - 0.1) * k;
feeds.lucerne = 0.1 + (maxYoung.lucerne - 0.1) * k;
feeds.turneps = 0.1 + (maxYoung.turneps - 0.1) * k;
feeds.beet = 0.1 + (maxYoung.beet - 0.1) * k;
feeds.rutabaga = 0.1 + (maxYoung.rutabaga - 0.1) * k;
feeds.oats = 0.1 + (maxYoung.oats - 0.1) * k;
} else if (day <= 240) {
const base = (type === 'bull') ? adult1_bull : adult1_cow;
feeds = { milk: 0, ...base };
} else if (day <= 420) {
const base = (type === 'bull') ? adult2_bull : adult2_cow;
feeds = { milk: 0, ...base };
} else {
const k = (480 - day) / 59;
feeds.milk = 0;
feeds.feed = 0.1 + (oldMax.feed - 0.1) * k;
feeds.lucerne = 0.1 + (oldMax.lucerne - 0.1) * k;
feeds.turneps = 0.1 + (oldMax.turneps - 0.1) * k;
feeds.beet = 0.1 + (oldMax.beet - 0.1) * k;
feeds.rutabaga = 0.1 + (oldMax.rutabaga - 0.1) * k;
feeds.oats = 0.1 + (oldMax.oats - 0.1) * k;
}
const tbody = document.getElementById('feedsTable');
tbody.innerHTML = '';
const names = {
milk: 'Молоко',
feed: 'Комбикорм',
lucerne: 'Люцерна',
turneps: 'Турнепс',
beet: 'Кормовая свекла',
rutabaga: 'Брюква',
oats: 'Овес'
};
for (let key in names) {
const tr = document.createElement('tr');
tr.innerHTML = `<td>${names[key]}
</td><td>${feeds[key].toFixed(2)}
</td>`;
tbody.appendChild(tr);
}
}