時給計算アプリ
時間と収入を入力してください。
<!DOCTYPE html>
<html>
<head>
<title>時給計算アプリ</title>
<script>
function calculateWage() {
const time = parseFloat(document.getElementById("working-hours").value);
const income = parseFloat(document.getElementById("income").value);
if (!isNaN(time) && !isNaN(income) && time > 0 && income > 0) {
const wage = income / time;
document.getElementById("wage-result").textContent = `あなたの時給は${wage.toFixed(2)}円です!`;
} else {
document.getElementById("wage-result").textContent =
"有効な値を入力してください。時間と収入は両方とも0より大きい数値である必要があります。";
}
}
</script>
</head>
<body>
<h1>時給計算アプリ</h1>
<p>時間と収入を入力してください。</p>
<label for="working-hours">勤務時間(時間):</label>
<input type="number" id="working-hours" /><br />
<label for="income">収入(円):</label>
<input type="number" id="income" /><br />
<br />
<button onclick="calculateWage()">計算する</button>
<br />
<br />
<p id="wage-result"></p>
</body>
</html>
※ジョークは割愛しました。