0
대출 상환 목록에 붙어있어서 마지막 항목 만 여러 번 제공합니다. 내 방법 :대출 상환은 마지막 항목만을 반환합니다. Java
public List<AmortizationScheduleLineItem> calculateAmortizationSchedule() {
List<AmortizationScheduleLineItem> lineItems = new ArrayList<AmortizationScheduleLineItem>();
AmortizationScheduleLineItem item = new AmortizationScheduleLineItem();
long balance = amountBorrowed;
int paymentNumber = 0;
long totalPayments = 0;
long totalInterestPaid = 0;
item.setPaymentNumber(paymentNumber++);
item.setPaymentAmount(0d);
item.setPaymentInterest(0d);
item.setCurrentBalance(((double) amountBorrowed)/100d);
item.setTotalPayments(((double) totalPayments)/100d);
item.setTotalInterestPaid(((double) totalInterestPaid)/100d);
lineItems.add(item);
final int maxNumberOfPayments = initialTermMonths + 1;
while ((balance > 0) && (paymentNumber <= maxNumberOfPayments)) {
long curMonthlyInterest = Math.round(((double) balance) * monthlyInterest);
long curPayoffAmount = balance + curMonthlyInterest;
long curMonthlyPaymentAmount = Math.min(monthlyPaymentAmount, curPayoffAmount);
if ((paymentNumber == maxNumberOfPayments)
&& ((curMonthlyPaymentAmount == 0) || (curMonthlyPaymentAmount == curMonthlyInterest))) {
curMonthlyPaymentAmount = curPayoffAmount;
}
long curMonthlyPrincipalPaid = curMonthlyPaymentAmount - curMonthlyInterest;
long curBalance = balance - curMonthlyPrincipalPaid;
totalPayments += curMonthlyPaymentAmount;
totalInterestPaid += curMonthlyInterest;
item.setPaymentNumber(paymentNumber++);
item.setPaymentAmount(((double) curMonthlyPaymentAmount)/100d);
item.setPaymentInterest(((double) curMonthlyInterest)/100d);
item.setCurrentBalance(((double) curBalance)/100d);
item.setTotalPayments(((double) totalPayments)/100d);
item.setTotalInterestPaid(((double) totalInterestPaid)/100d);
lineItems.add(item);
// Set P equal to Q and go back to Step 1: You thusly loop around until the value Q (and hence P) goes to zero.
balance = curBalance;
}
return lineItems;
}
내 웹 서비스 방법 :
@WebResult(name = "PaymentPlan")
@WebMethod(operationName = "GetLoanPaymentPlan")
public List<AmortizationScheduleLineItem> GetLoanPaymentPlan() {
AmortizationScheduleInput input = new AmortizationScheduleConsoleInputOutput().readUserInputFromConsole();
LoanAmortizationSchedule loan = new LoanAmortizationSchedule(input);
return loan.calculateAmortizationSchedule();
}
내 응답 :
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:GetLoanPaymentPlanResponse xmlns:ns2="http://service.dfcu.com/">
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
<PaymentPlan>
<currentBalance>0.0</currentBalance>
<paymentAmount>0.05</paymentAmount>
<paymentInterest>0.0</paymentInterest>
<paymentNumber>61</paymentNumber>
<totalInterestPaid>396095.05</totalInterestPaid>
<totalPayments>1396095.05</totalPayments>
</PaymentPlan>
</ns2:GetLoanPaymentPlanResponse>
</S:Body>
</S:Envelope>
내가 목록에서 다른 항목을 얻을합니까?
와우, OK 감사합니다 모든 시간을 동일한 개체에서 작업 루프의 각 반복에 새 항목 객체를 생성해야합니다. 그게 효과가 있었어. – ErrorNotFoundException
당신은 환영합니다 –
btw 중복;) –