Compounding C-language to Java-related code

Source: Internet
Author: User

Static voidPrincipal ()//Calculate principal{    intN, M; DoubleI, F, P; System. out. printf ("Compounding End Value:"); F=scanner.nextdouble (); System. out. printf ("Annual interest Rate:"); I=scanner.nextdouble (); System. out. printf ("Deposit Life:"); N=Scanner.nextint (); System. out. printf ("Annual Compounding Times:"); M=Scanner.nextint (); //P = Capital_formula (F, I, N, M);P = F/math.pow ((1+ i/m), N *m); System. out. println ("Annual compounding end value is", A +"the required principal is:"+P);}Static voidYear_end_value ()//Calculate compounding End value{    intN, M; DoubleI, F, P; System. out. printf ("deposited Capital:"); P=scanner.nextdouble (); System. out. printf ("Annual interest Rate:"); I=scanner.nextdouble (); System. out. printf ("Deposit Life:"); N=Scanner.nextint (); System. out. printf ("Annual Compounding Times:"); M=Scanner.nextint (); F= P * MATH.POW ((1+ i/m), N *m); System. out. println ("Compounding End Value:"+F);}Static voidDanli ()//Simple Interest Calculation{    intN; DoubleI, F, P; System. out. printf ("deposited Capital:"); P=scanner.nextdouble (); System. out. printf ("Annual interest Rate:"); I=scanner.nextdouble (); System. out. printf ("Deposit Life:"); N=Scanner.nextint (); F= p + P * N *i; System. out. println ("principal and interest and for:"+F);}Static voidYears ()//To find the year{    intYear , M; DoubleI, F, P; System. out. printf ("Compounding End Value:"); F=scanner.nextdouble (); System. out. printf ("deposited Capital:"); P=scanner.nextdouble (); System. out. printf ("Annual interest Rate:"); I=scanner.nextdouble (); System. out. printf ("Annual Compounding Times:"); M=Scanner.nextint (); year= (int) (Math.log (f/p)/Math.log (1+ i/m)/m); System. out. println ("from", W +"to the", A +"need to"+ year +"years");}Static voidAPY ()//Calculate annual interest rate{    intN, M; DoubleRate , F, P; System. out. printf ("Compounding End Value:"); F=scanner.nextdouble (); System. out. printf ("deposited Capital:"); P=scanner.nextdouble (); System. out. printf ("Deposit Life:"); N=Scanner.nextint (); System. out. printf ("Annual Compounding Times:"); M=Scanner.nextint (); Rate= M * (Math.pow (f/p,1.0/(N * m))-1); System. out. println ("from", W +"to the", A +"need to"+Rate );}Static voidInvestment ()//calculate a matching investment{    intN, N; DoubleI, Final_value, P; System. out. printf ("\T\T1: Investment by year \N\T\T2: monthly investment \ n"); System. out. printf ("Please select the function you want <1|2>:"); N=Scanner.nextint (); if(n = =1) {System. out. printf ("deposited Capital:"); P=scanner.nextdouble (); System. out. printf ("Deposit Life:"); N=Scanner.nextint (); System. out. printf ("Annual interest Rate:"); I=scanner.nextdouble (); Final_value= P * (Math.pow (1+ I, N)-1) /i; System. out. println (N +"the total output after the year:"+final_value); } Else if(n = =2) {System. out. printf ("deposited Capital:"); P=scanner.nextdouble (); System. out. printf ("Deposit Life:"); N=Scanner.nextint (); System. out. printf ("Annual interest Rate:"); I=scanner.nextdouble (); Final_value= P * A* (1+ i) * (Math.pow (1+ I, N)-1) /i; System. out. println (N +"the total output after the year:"+final_value); } Else{System. out. printf ("input Error!\n"); }}Static voidRepayment ()//Equal repayment{    intN; DoubleI, F, refund; System. out. printf ("Loan Amount:"); F=scanner.nextdouble (); System. out. printf ("Deposit Life:"); N=Scanner.nextint (); System. out. printf ("Annual interest Rate:"); I=scanner.nextdouble (); Refund= F * I/( A* (1+ i) * (Math.pow (1+ I, N)-1)); System. out. println ("Loans", A +"Monthly repayment Required"+refund);}}

Compounding C-language to Java-related code

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.