모든 도움을 주시면 감사하겠습니다. 현재 프롬프트로 사용자 입력에 문제가있어 변수로 저장되므로 for 루프를 통과 한 다음 테이블에 삽입 할 수 있습니다. 내 실수는 테이블에 인서트를 포맷하는 방식에 있음을 확신합니다.ParseInt 프롬프트가 테이블에 표시되지 않습니다.
var investment = parseInt(prompt("What will be your initial investment?", "0"), 10);
var interest_rate = parseInt(prompt("What will be your interest rate?", "0"), 10);
var deposit_amount = parseInt(prompt("What will be your monthly deposit?", "0"), 10);
var start_age = parseInt(prompt("What is your age?", "0"), 10);
var beg_balance = 0;
var end_balance = 0;
var daily_interest_rate = interest_rate/365;
var calculated_interest = 0;
var accrued_interest = 0;
var cumulative_deposits = 0;
var day = 0;
document.write("<table>")
document.write("<tr><th>Age</th><th>Beg Balance</th><th>Interest</th><th>Deposits</th><th>Ending Balance</th></tr>")
beg_balance = investment;
for (var yearly = start_age + 1; yearly <= end_age; yearly++)
{
for (var daily = 1; daily <= 365; daily++)
{
day++;
calculated_interest = (daily_interest_rate) * (beg_balance + cumulative_deposits + accrued_interest);
accrued_interest += calculated_interest;
if (day == 30)
{
day = 0;
cumulative_deposits += deposit_amount;
}
}
end_balance = beg_balance + cumulative_deposits + accrued_interest;
document.write("<tr>");
document.write("<td>" + yearly.toFixed(2) + "</td><td>" + beg_balance.toFixed(2) + "</td><td>" + accrued_interest.toFixed(2) + "</td><td>" + cumulative_deposits.toFixed(2) + "</td><td>" + end_balance.toFixed(2) + "</td>");
document.write("</tr>");
beg_balance = end_balance;
cumulative_deposits = 0;
accrued_interest = 0;
}
document.write("</table>")
Document.write는 문자열을 쓰는 것과 같지 않습니다. 여는 태그를 쓸 때 브라우저가 닫습니다. – epascarello