Bifalgorithm post · Computer science one · Paying the Piper
What is 28?
What is 28? (Computer science one · Paying the Piper) — "28. Loops 1 public class LoanAmortization { 2 3 public static void main(String args[]) { 4 5 if(args.l…
Ideas in this flowchart
- Loan amortization program using a payment loop
- Checks whether exactly four command-line arguments were provided
- Prints the usage message and exits when the argument count is invalid
- Parses the principal, APR, and number of months
- Initializes the balance to the loan principal
- Converts the annual percentage rate into a monthly interest rate
- Calculates the fixed monthly payment from the loan formula
- Rounds the monthly payment to the nearest cent
- Prints the principal, APR, term, and monthly payment
- Repeats the amortization process for the first n−1 payments
- Computes and rounds the interest for the current balance
- Computes the principal payment by subtracting interest from the payment
- Updates the balance by subtracting the principal payment
- Prints the payment number, interest, principal payment, and new balance