我已经尝试了我能想到的一切,不知道是什么导致了这个逻辑问题!请帮助,非常感谢任何提示或想法。解决方案 100000.00 时间= 30年 低价格= 11% 高利率= 12% 11.00 952.32 11.25 971.26 11.50 990.29 11.75 1009.41 12.00 1028.61 公式: 确定付款的公式为:(p * k * c)/(c - 1) p =本金,借入金额 k =月利率(年利率/12.0) n =每月付款次数(年* 12) c =(1 + k)^ n a =每月付款(支付利息和本金) 我已经尝试了我能想到的一切,不知道是什么导致这个逻辑问题!请提供帮助,非常感谢任何提示或想法。 MAIN:package loantable;import java.util.ArrayList;public class LoanTable{ private double loanAmount; private double loanLength; private double lowInterest; private double highInterest; private int count; ArrayList<Double> payments = new ArrayList<>(); public LoanTable(double loanAmount, double loanLength, double lowInterest, double highInterest) { this.loanAmount = loanAmount; this.loanLength = loanLength; this.lowInterest = lowInterest; this.highInterest = highInterest; } public ArrayList getInterestRates() { count = -1; while(lowInterest <= highInterest) { double monthlyInterest = lowInterest / 12.0; double length = loanLength * 12; double c = Math.pow((1 + monthlyInterest), length); double monthlyPayment = (loanAmount * monthlyInterest * c)/ (c - 1); payments.add(monthlyPayment); lowInterest += .25; count++; } return payments; } public String to() { String theory = ""; double currentInterest = highInterest; ArrayList<Double> t = new ArrayList<>(); t = getInterestRates(); while(count >= 0) { theory = theory + "\n" + "Interest Rate: " + currentInterest + " Monthly Payment: " + t.get(count); count--; currentInterest -= .25; } return theory; }}TESTER:package loantable;import java.util.Scanner;public class LoanTableTester { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("Principal: "); double loanAmount = sc.nextDouble(); System.out.print("\nTime: "); double time = sc.nextDouble(); System.out.println("\nLow Rate: "); double lowRate = sc.nextDouble(); System.out.println("\nHigh Rate: "); double highRate = sc.nextDouble(); LoanTable t = new LoanTable(loanAmount, time, lowRate, highRate); System.out.println(t.to()); }}CONSOLE:Principal: 100000Time: 30Low Rate: 11High Rate: 12Interest Rate: 12.0 Monthly Payment: 100000.0Interest Rate: 11.75 Monthly Payment: 97916.66666666666Interest Rate: 11.5 Monthly Payment: 95833.33333333334Interest Rate: 11.25 Monthly Payment: 93750.0Interest Rate: 11.0 Monthly Payment: 91666.66666666664CORRECT ANSWER:Principal = $100000.00Time = 30 yearsLow rate = 11%High rate = 12% 11.00 952.32 11.25 971.26 11.50 990.29 11.75 1009.41 12.00 1028.61FORMULA:The formula for determining payments is:(p * k * c)/ (c - 1)p = principal, amount borrowedk = monthly interest rate (annual rate/12.0)n = number of monthly payments (years * 12)c = (1 + k)^na = monthly payment (interest and principal paid)I have tried everything I can think of, not sure what is causing this logic issue! Please help, any tips or ideas are greatly appreciated. 解决方案 100000.00Time = 30 yearsLow rate = 11%High rate = 12% 11.00 952.32 11.25 971.26 11.50 990.29 11.75 1009.41 12.00 1028.61FORMULA:The formula for determining payments is:(p * k * c)/ (c - 1)p = principal, amount borrowedk = monthly interest rate (annual rate/12.0)n = number of monthly payments (years * 12)c = (1 + k)^na = monthly payment (interest and principal paid)I have tried everything I can think of, not sure what is causing this logic issue! Please help, any tips or ideas are greatly appreciated. 这篇关于利息计算器中的逻辑错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-26 21:51