[Solved] Java Payment Installments Calculator [closed]


It is simple mathematics: You have a numberOfInstallments, the totalAmount and an initialInstallment.

  • First get the left over amount with totalAmount - initialInstallment.
  • Next divide by numberOfInstallments.

In Java is becomes something like this:

int totalAmount = 15000;
int initialInstallment = 5000;
int numberOfInstallments = 5;

// Calculate the height of each installment
int installment = (totalAmount - initialInstallment) / numberOfInstallments;

// Print to screen
for(int i = 1; i <= numberOfInstallments) {
    System.out.println("Installment " + i + "  " + installment);
}
System.out.println("Total " + (totalAmount - initialInstallment));

(I did not bother to properly align the output, but that should not be too hard.)

0

solved Java Payment Installments Calculator [closed]