حاسبة التغذية

<div style=”max-width: 600px; margin: auto;”>
<h2>حاسبة التغذية الذكية</h2>
<form id=”feedForm”>
<label>نوع الحيوان:</label>
<select id=”animalType” required>
<option value=””>اختر</option>
<option value=”cow”>بقرة</option>
<option value=”goat”>ماعز</option>
<option value=”sheep”>غنم</option>
<option value=”chicken”>دواجن</option>
</select><br><br>

<label>الوزن (كجم):</label>
<input type=”number” id=”weight” min=”1″ required><br><br>

<label>العمر (بالأشهر):</label>
<input type=”number” id=”age” min=”1″ required><br><br>

<label>الهدف:</label>
<select id=”goal” required>
<option value=””>اختر</option>
<option value=”fattening”>تسمين</option>
<option value=”milk”>إنتاج الحليب</option>
<option value=”eggs”>إنتاج البيض</option>
</select><br><br>

<button type=”submit”>احسب التغذية</button>
</form>

<div id=”result” style=”margin-top: 30px;”></div>
</div>

<script>
document.getElementById(“feedForm”).addEventListener(“submit”, function (e) {
e.preventDefault();
const type = document.getElementById(“animalType”).value;
const weight = parseFloat(document.getElementById(“weight”).value);
const age = parseInt(document.getElementById(“age”).value);
const goal = document.getElementById(“goal”).value;

let feed = {}, water = 0;

if (type === “cow”) {
if (goal === “fattening”) {
feed = {
“علف مركز”: (0.02 * weight).toFixed(2) + ” كجم”,
“تبن أو دريس”: (0.015 * weight).toFixed(2) + ” كجم”,
“أعلاف خضراء”: (0.05 * weight).toFixed(2) + ” كجم”,
“أملاح معدنية”: “50 جم”
};
water = (weight * 0.08).toFixed(1);
} else if (goal === “milk”) {
feed = {
“علف مركز”: (0.03 * weight).toFixed(2) + ” كجم”,
“تبن أو دريس”: (0.015 * weight).toFixed(2) + ” كجم”,
“أعلاف خضراء”: (0.04 * weight).toFixed(2) + ” كجم”,
“أملاح معدنية”: “70 جم”
};
water = (weight * 0.1).toFixed(1);
}
}

else if (type === “goat” || type === “sheep”) {
feed = {
“علف مركز”: (0.04 * weight).toFixed(2) + ” كجم”,
“تبن أو دريس”: (0.02 * weight).toFixed(2) + ” كجم”,
“أعلاف خضراء”: (0.05 * weight).toFixed(2) + ” كجم”,
“أملاح معدنية”: “30 جم”
};
water = (weight * 0.06).toFixed(1);
}

else if (type === “chicken”) {
if (goal === “fattening”) {
feed = { “علف تسمين”: “120 جم/اليوم” };
water = “300 مل/اليوم”;
} else if (goal === “eggs”) {
feed = { “علف بياض”: “100 جم/اليوم”, “كالسيوم”: “4 جم” };
water = “250 مل/اليوم”;
}
}

let output = `<h3>توصية التغذية اليومية:</h3><ul>`;
for (let item in feed) {
output += `<li><b>${item}</b>: ${feed[item]}</li>`;
}
output += `</ul><b>الماء:</b> ${water} لتر يوميًا`;

document.getElementById(“result”).innerHTML = output;
});
</script>

زر الذهاب إلى الأعلى