银行理财计算器在线使用
body {
fontfamily: Arial, sansserif;
margin: 0;
padding: 20px;
}
h1 {
textalign: center;
marginbottom: 30px;
}
.calculator {
width: 80%;
margin: 0 auto;
border: 1px solid ccc;
padding: 20px;
backgroundcolor: f9f9f9;
}
.formgroup {
marginbottom: 20px;
}
label {
display: block;
marginbottom: 5px;
}
input[type="number"], select {
width: 100%;
padding: 5px;
marginbottom: 10px;
border: 1px solid ccc;
borderradius: 3px;
}
button {
backgroundcolor: 4CAF50;
color: white;
padding: 10px 20px;
border: none;
cursor: pointer;
borderradius: 3px;
margintop: 20px;
}
.result {
fontweight: bold;
margintop: 30px;
}
银行理财计算器
function calculate() {
const principal = parseFloat(document.getElementById("principal").value);
const rate = parseFloat(document.getElementById("rate").value) / 100; // 转换为小数
const period = parseInt(document.getElementById("period").value);
// 理财公式: A = P * (1 r/n)^(nt)
// A: 未来值, P: 本金, r: 年利率, n: 每期利率, t: 投资期数
const futureValue = principal * Math.pow(1 rate / period, period);
document.getElementById("result").innerHTML = `未来值: ${futureValue.toFixed(2)}元`;
}