Membuat Kalkulator Menghitung Bunga dalam Sistem Perbankan.
Kalkulator Bunga Bank
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Kalkulator Bunga Bank</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
body {
background-color: #f8f9fa;
padding: 20px;
}
.container {
max-width: 400px;
margin: 0 auto;
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.form-group {
margin-bottom: 20px;
}
.btn {
width: 100%;
}
</style>
</head>
<body>
<div class="container">
<h2 class="text-center">Kalkulator Bunga Bank</h2>
<form id="calculatorForm">
<div class="form-group">
<label for="principal">Pokok Pinjaman (Rp)</label>
<input type="number" class="form-control" id="principal" required>
</div>
<div class="form-group">
<label for="interest">Bunga per Tahun (%)</label>
<input type="number" class="form-control" id="interest" required>
</div>
<div class="form-group">
<label for="years">Lama Pinjaman (Tahun)</label>
<input type="number" class="form-control" id="years" required>
</div>
<button type="submit" class="btn btn-primary">Hitung</button>
</form>
<div id="result" class="mt-3"></div>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script>
document.getElementById('calculatorForm').addEventListener('submit', function (e) {
e.preventDefault();
const principal = parseFloat(document.getElementById('principal').value);
const interest = parseFloat(document.getElementById('interest').value) / 100;
const years = parseFloat(document.getElementById('years').value);
const totalAmount = principal + (principal * interest * years);
const interestAmount = principal * interest * years;
document.getElementById('result').innerHTML = `
<h4>Hasil Perhitungan</h4>
<p>Pokok Pinjaman: Rp ${principal}</p>
<p>Bunga: Rp ${interestAmount}</p>
<p>Total yang Harus Dibayar: Rp ${totalAmount}</p>
`;
});
</script>
</body>
</html>
HTMLSemoga kalkulator ini dapat membantu dalam menghitung bunga dalam sistem perbankan dengan lebih mudah dan efisien.
Leave a Reply