간이 주택 대출 월 공급 계산기

4190 단어 C 언어
다음은 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, 더블 클릭하면 브라우저에서 실행할 수 있습니다.

좋은 웹페이지 즐겨찾기