The next two () methods will be used to display the calculated result of simple and compound interest. Similarly the formula for compound interest is: pr * Math.pow(1.0+rate/100.0,t) - pr and its calculated value will be assigned to variable com. So the statement will be: (pr * t * rate)/100 which will get assigned to variable sim. Now you have to use the formula for simple interest to calculate the SI with the given values. The methods used in this article are as follows: Using Standard Method Using Static Method Using Separate Class Mortgage Payment, as we all know. If you have any queries leave a comment here. Similarly the values for time and rate will also be fetched from the user using sc.nextDouble(). Java Program To Calculate Mortgage Payment The following java code has been written in 3 simple ways for mortgage payment calculator. My 'Account informations' has to be stored in an Array. Don't think about security issues and such in this example, I just need help to get it right. Then the statement pr=sc.nextDouble() will be used to fetch the value from keyboard, and parse it to integer from string and store to variable pr. I'm very new to Java, and I want to make a very simple login Java-program. Then () method will be used to display a message - "Enter the amount:". Also define an object name s of Scanner class using which the value will be fetched from input device. Next declare a double type variable name pr, rate, t, sim and com. All Java program needs one main() function from where it starts executing program. Inside the class define the main() function. println("Compound Interest="+com) įirst you have to import the util package of Java so that you can use the Scanner class in this program which will help programmers to fetch input from users. println("Enter the Rate of interest") Ĭom=pr * Math.pow(1.0+rate/100.0,t) - pr
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |