This article describes the loan amount calculation function implemented by Java. Share it for your reference, as follows:
Questions and codes:
/**Copyright (c) 2015, Southwest University School of Planning and Information Technology*All rights reserved.*File name: Helloworld.java*Author: Gaoshuo*Completion date: October 15, 2015*version number: v1.0*Problem description: Calculate monthly payment amount and total payment amount through annual interest rates, etc. *Program input: annual interest rate, time, amount. *Program output: monthly payment amount and total payment amount. */package practice_01;import java.util.Scanner;public class ComputeLoan { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("Wulin.com test result:"); Scanner input=new Scanner(System.in); System.out.println("please input the yearly rate"); double yearlyrate =input.nextDouble(); double monthlyrate=yearlyrate/1200; System.out.println("please input the number of years"); int number =input.nextInt(); System.out.println("please input the amount"); double amount =input.nextDouble(); double monthlypayment=amount* monthlyrate/1-1/Math.pow(1+monthlyrate,number*12); double totalpayment=monthlypayment*number*12; System.out.println("the monthly payment is " + (int)(monthlypayment*100) /100.0) ; System.out.println("the total payment is " + (int)(totalpayment)*100 ) ; }}Running results:
Summary of knowledge points:
Cases of data types (explicit conversion), Math.pow, priority
Experience:
It feels like Java's priority is similar to others. Java has very strict requirements on types and will not automatically convert them all. Small types become larger and types can be broadened. If large types become smaller and types do not convert, errors will occur.
Also, if the variable types are assigned differently, there will be errors that will not be converted. For example, assign int to short or byte.
At first I didn't feel that it was too troublesome, but now it seems a bit troublesome. . I don't quite understand the meaning of object-oriented. Ao ~~
Finally, record a knowledge point: There are some "' line breaks, carriage return, tab, etc. in the output statement in Java that cannot be used, and escape characters can be used, such as:
Double quotes are /"Single quotes are /' Backspace is /b tab is /t newline/n enter/r backslash//
PS: Here are a few calculation tools for you to refer to:
Online Loan Calculator:
http://tools.VeVB.COM/jisuanqi/daikuan_jisuanqi
Online Bank Mortgage Loan Calculator:
http://tools.VeVB.COM/jisuanqi/anjie_calc
Scientific Calculator Online Use_Advanced Calculator Online Calculator:
http://tools.VeVB.COM/jisuanqi/jsqkeexue
Online Calculator_Standard Calculator:
http://tools.VeVB.COM/jisuanqi/jsq
For more information about Java algorithms, readers who are interested in this site can view the topics: "Java Data Structure and Algorithm Tutorial", "Summary of Java Operation DOM Node Tips", "Summary of Java File and Directory Operation Tips" and "Summary of Java Cache Operation Tips"
I hope this article will be helpful to everyone's Java programming.