愛車の売り時判断アプリ
年
以下は、ユーザーの要望に基づいて作成したプログラムです。入力フォームを提供し、それぞれの値を取得し、愛車の売り時を判断するための条件分岐を行います。
```html
<!DOCTYPE html>
<html>
<head>
<title>愛車の売り時判断アプリ</title>
<script>
// 売り時を判断する関数
function determineSellTiming() {
// 入力値を取得
var appraisalPrice = parseFloat(document.getElementById("appraisalPrice").value);
var purchasePrice = parseFloat(document.getElementById("purchasePrice").value);
var remainingLoan = parseFloat(document.getElementById("remainingLoan").value);
var purchaseDuration = parseInt(document.getElementById("purchaseDuration").value);
// 売り時の判断
if (remainingLoan <= 0) {
showResult("返済が完了しているため、いつでも売れます!");
} else if (appraisalPrice >= remainingLoan) {
showResult("査定額が残りのローンを上回っているため、今が売り時です!");
} else {
var loanPayedMonths = Math.floor(purchaseDuration / 12);
var loanPayedYears = purchaseDuration % 12;
var result = "次に売り時を迎えるのは";
if (loanPayedMonths > 0) {
result += loanPayedMonths + "ヶ月後の";
}
if (loanPayedYears > 0) {
result += loanPayedYears + "年後です!";
}
showResult(result);
}
}
// 結果を表示する関数
function showResult(result) {
document.getElementById("result").textContent = result;
}
</script>
</head>
<body>
<h1>愛車の売り時判断アプリ</h1>
<label for="appraisalPrice">査定額(万円):</label>
<input type="number" step="0.01" id="appraisalPrice" required><br>
<label for="purchasePrice">購入額(万円):</label>
<input type="number" step="0.01" id="purchasePrice" required><br>
<label for="remainingLoan">残りのローン(万円):</label>
<input type="number" step="0.01" id="remainingLoan" required><br>
<label for="purchaseDuration">購入後の年月:</label>
<input type="number" id="purchaseDuration" required>年<br>
<button onclick="determineSellTiming()">売り時を判断する</button>
<h2 id="result"></h2>
</body>
</html>
```
このプログラムは、査定額、購入額、残りのローン、購入後の年月を入力して「売り時を判断する」ボタンをクリックすると、売り時の結果が表示されます。
なお、面白いジョークを取り入れるという要望がありましたので、以下に愛車に関連するジョークを追加しました。
```html
<!DOCTYPE html>
<html>
<head>
<title>愛車の売り時判断アプリ</title>
<script>
// 売り時を判断する関数
function determineSellTiming() {
// 入力値を取得
var appraisalPrice = parseFloat(document.getElementById("appraisalPrice").value);
var purchasePrice = parseFloat(document.getElementById("purchasePrice").value);
var remainingLoan = parseFloat(document.getElementById("remainingLoan").value);
var purchaseDuration = parseInt(document.getElementById("purchaseDuration").value);
// 売り時の判断
if (remainingLoan <= 0) {
showResult("返済が完了しているため、いつでも売れます! スピード違反をせずに安全運転でお願いします!");
} else if (appraisalPrice >= remainingLoan) {
showResult("査定額が残りのローンを上回っているため、今が売り時です! ローン返済に頑張ったご褒美の一台をお楽しみください!");
} else {
var loanPayedMonths = Math.floor(purchaseDuration / 12);
var loanPayedYears = purchaseDuration % 12;
var result = "次に売り時を迎えるのは";
if (loanPayedMonths > 0) {
result += loanPayedMonths + "ヶ月後の";
}
if (loanPayedYears > 0) {
result += loanPayedYears + "年後です! メンテナンスに気をつけて大切に乗ってくださいね!";
}
showResult(result);
}
}
// 結果を表示する関数
function showResult(result) {
document.getElementById("result").textContent = result;
}
</script>
</head>
<body>
<h1>愛車の売り時判断アプリ</h1>
<label for="appraisalPrice">査定額(万円):</label>
<input type="number" step="0.01" id="appraisalPrice" required><br>
<label for="purchasePrice">購入額(万円):</label>
<input type="number" step="0.01" id="purchasePrice" required><br>
<label for="remainingLoan">残りのローン(万円):</label>
<input type="number" step="0.01" id="remainingLoan" required><br>
<label for="purchaseDuration">購入後の年月:</label>
<input type="number" id="purchaseDuration" required>年<br>
<button onclick="determineSellTiming()">売り時を判断する</button>
<h2 id="result"></h2>
<hr>
<h3>愛車に関するジョーク</h3>
<p>なぜ愛車が泣いているのか分かりますか?<br>カーレーサーになりたいと言ったからです!</p>
</body>
</html>
```
このプログラムでは、ジョークが「愛車に関するジョーク」というセクションとして表示されます。