간이 주택 대출 월 공급 계산기
4190 단어 C 언어
#include "stdio.h"
#include "math.h"
int main()
{
double amountOfLoan,annualInterest,repaymentPeriod; //input
double monthlyPayments; //output
double monthlyInterest,numOfMonth,tmp; // intermediate variables
//Input
printf("
A simple loan calculator
");
printf(" Please input amount of loan(¥):");
scanf("%lf",&amountOfLoan);
printf("
Please input annual interest(%%):");
scanf("%lf",&annualInterest);
printf("
Please input repayment period(years):");
scanf("%lf",&repaymentPeriod);
//calculate
monthlyInterest = annualInterest/100/12;
numOfMonth = repaymentPeriod*12;
tmp = pow(1+monthlyInterest,numOfMonth);
monthlyPayments = (amountOfLoan * tmp * monthlyInterest)/(tmp-1);
//output
printf("
You need to repay ¥%.2f each month. Good luck!
",monthlyPayments);
return 0;
}
다음은 HTML, CSS, 자바스크립트 스크립트 언어로 작성된 간단한 대출 월간 계산기입니다. 브라우저에서 실행할 수 있습니다.HTML은 웹 요소를 정의하고 CSS는 페이지 스타일을 정의하며 자바스크립트는 핵심적인 계산 부분을 실현했다.자바스크립트 세션(라벨과 사이의 코드)의 실현 사고방식은 위에서 쓴 C 언어 코드와 비슷하다. 먼저 데이터를 얻은 다음에 수학 라이브러리 함수를 빌려 계산하고 마지막에 결과를 출력한다.다른 것은 웹 페이지의 텍스트 상자에서 데이터를 얻고 결과도 페이지 요소에 나타난다는 것이다.
JavaScript Loan Calculator
JavaScript Loan Calculator
Amount of the loan(¥):
Annual interest(%):
Repayment period(years):
Approximate Payments:
Monthly Payments:
¥
Total Payments:
¥
Total Interest:
¥
"use strict";
function $(id){
return document.getElementById(id);
}
function calculate ()
{
var amount = $('amount');
var apr = $('apr');
var years = $('years');
var payment = $('payment');
var total = $('total');
var totalinterest = $('totalinterest');
var principal = parseFloat(amount.value);
var interest = parseFloat(apr.value)/100/12;
var payments = parseFloat(years.value)*12;
var x = Math.pow(1+interest ,payments);
var monthly = (principal * x * interest)/(x-1);
if(isFinite(monthly))
{
payment.innerHTML = monthly.toFixed(2);
total.innerHTML = (monthly*payments).toFixed(2);
totalinterest.innerHTML = ((monthly*payments)-principal).toFixed(2);
}
}
상술한 코드를 텍스트 문서로 복사하고 접미사 이름을 변경합니다.html, 더블 클릭하면 브라우저에서 실행할 수 있습니다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
C 언어 구현 천둥 제거 게임 상세 정보먼저 작은 메뉴를 표시하고 게임을 할지 여부를 선택하십시오.사용자가 종료를 선택하면 프로그램 실행이 끝나고, 사용자가 게임을 선택하면 지뢰 제거 위치 좌표를 입력하라는 메시지가 표시됩니다.사용자가 입력한 좌표가 바둑...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.