我有一项作业要求我计算复利。我做了大部分功课,但我应该显示“存款金额”,其中包含 2 位小数的美分。parseFloat()
但是我尝试了一些类似or 的东西,toFixed
但我仍然不能以 2 的精度获取结果,我只能使用00.00
. 我需要这样的解决方案:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="Cersoy-CNIT133-Assignments-4-part2" content="Cersoy-CNIT133-Assignments-4part2">
<meta name='viewport' content='width=device-width, initial-scale=1'>
<link href="../Assignment_all.css" type="text/css" rel="stylesheet">
<title>Cersoy-CNIT133-Assignments_4-Part2</title>
<style>
#main{
background-color: burlywood;
margin: auto;
height: 30%;
width: 50%;
padding: 1em;
text-align: center;
border-radius: 10px;
}
#table{
border: solid 1px black;
}
th{
border: solid 1px black;
}
td{
border: solid 1px black;
}
}
</style>
</head>
<body>
<header>
Cersoy-CNIT133-Assignments 4-Part2
</header>
<div id="main">
<table id="table1" >
<tr>
<th>Year</th>
<th>Amount of deposit</th>
<th>Intrest Rate</th>
</tr>
<table id="table2" >
<tr>
<th>Year</th>
<th>Amount of deposit</th>
<th>Intrest Rate</th>
</tr>
<table id="table3" >
<tr>
<th>Year</th>
<th>Amount of deposit</th>
<th>Intrest Rate</th>
</tr>
</table>
<script>
var rate1=5;rate2=6;rate3=7;
function addRow(a,b,c,t) {
var table=0;
if(t==1){table = document.getElementById("table1");}
if(t==2){
table = document.getElementById("table2");
}
else if(t==3){
table = document.getElementById("table3");
}
var row = table.insertRow(-1);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
cell1.innerHTML = a;
cell2.innerHTML = b;
cell3.innerHTML = c;
}
忽然笑
湖上湖
相关分类