Java-based loan amount calculation function example: java loan amount

Source: Internet
Author: User

Java-based loan amount calculation function example: java loan amount

This example describes the loan amount calculation function implemented by Java. We will share this with you for your reference. The details are as follows:

Problem and code:

/** Copyright (c) 2015, Southwest University, School of information and design * All rights reserved. * file name: Helloworld. java * Author: Gao Shuo * Completion Date: July 15, October 15, 2015 * version No.: v1.0 * Problem description: monthly payment amount and total payment are calculated based on the annual interest rate. * Program input: annual interest rate, time, and amount. * Program output: monthly payment amount and total payment amount. */Package practice_01; import java. util. extends; public class ComputeLoan {public static void main (String [] args) {// TODO Auto-generated method stub System. out. println ("helper house Test Result:"); partition input = new partition (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 result:

Knowledge Point summary:

Forced conversion (explicit conversion) of data types, Math. pow, priority

Experience:

The java priority is similar to that of others. Java has strict requirements on types and does not automatically convert all types. Small data types can be extended, while large data types can be extended. errors may occur if conversion is not performed.

In addition, an error occurs when values of different variable types are not converted. For example, assign an int value to short or byte.

At the beginning, I didn't feel much trouble. Now it seems a little troublesome .. I still don't quite understand what object-oriented means. Zookeeper ~~

Finally, record a knowledge point: Some output statements in java contain escape characters, such as 'newline, carriage return, and tab, which cannot be used. For example:

Double quotation marks are \ "single quotation marks are \ '. The backspace is \ B tab is \ t line feed \ n carriage return \ r backslash \\

PS: Here are some recommended computing tools for your reference:

Online Loan calculator:
Http://tools.jb51.net/jisuanqi/daikuan_jisuanqi

Online bank mortgage loan calculator:
Http://tools.jb51.net/jisuanqi/anjie_calc

Scientific calculator online use _ advanced calculator online computing:
Http://tools.jb51.net/jisuanqi/jsqkexue

Online calculator _ standard calculator:
Http://tools.jb51.net/jisuanqi/jsq

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.