Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Bugs & Fixes 2 years ago
Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
I am a beginner attempting to create a small program in Java that allows a user to input their loan term, interest rate etc. and will hopefully spit out an estimate for monthly repayments. When i am doing this, however, it gives me a completely different number to what i've calculated manually.
I been told to use the BigDecimal math system as the primitive double data type is not accurate enough for financial calculations.
The steps i am doing are attempting to mimic this formula : M = P [i(1+i)^n/ 1-(1+i)^n]
BigDecimal iRateInput = BigDecimal.valueOf(iRate); BigDecimal twelve = new BigDecimal("12"); BigDecimal iRateMonthly = iRateInput.divide(twelve); BigDecimal one = new BigDecimal ("1"); BigDecimal iRateTemp = iRateMonthly.add(one); BigDecimal loanTermBD = BigDecimal.valueOf(loanTerm); loanTermBD = loanTermBD.multiply(twelve); BigDecimal iRatePower = iRateTemp.pow(loanTerm); BigDecimal iRateTop = iRateMonthly.multiply(iRatePower); BigDecimal iRateBottom = iRatePower.subtract(one); BigDecimal iRateTotal = iRateTop.divide(iRateBottom, BigDecimal.ROUND_UP); BigDecimal borrowAmountBD = BigDecimal.valueOf(borrowAmount); BigDecimal repayments = borrowAmountBD.multiply(iRateTotal);
I have been testing this code with:
P = 100,000
n = 15 years (*12)
r = 0.06p/a
According to my calculations, the monthly repayment should be 843.86 but I am getting 6936.43
Help would be appreciated! <3
private static double calculateRatePower(double rate, int period) { return Math.pow(1.0 + rate/12.0, period * 12.0); } public static void main(String[] args) throws IOException { double iRate = 0.06; double borrowAmount = 100000.0; int loanTerm = 15; double top = (iRate / 12.0) * calculateRatePower(iRate, loanTerm); double bottom = 1 - calculateRatePower(iRate, loanTerm); double repayments = borrowAmount * (top/bottom); System.out.println(repayments); }
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 9 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.