//========================================================================= #define PROGRAMMER "SOLUTIONS, Nofrills" #define PROG_CODE "soln" #define COURSE "ECE-1021" #define YEAR (2004) #define TERM "Spring" #define SECTION (0) #define ASSIGNMENT "HW5A" #define REVISION (0) #define TITLE "How much did that REALLY cost?" #define SUBTITLE "Last modified on 11 MAR 04" #define EMAIL "ece1021@eas.uccs.edu" #define FILENAME "05a0soln.txt" //========================================================================= //========================================================================= // PROBLEM //========================================================================= // Generate an amortization table for a credit card on which a single // purchase is made and which is paid back according to the minimum payment // terms of the card. //========================================================================= // PSEUDOCODE //========================================================================= // 1. TASK: Get Input Data from User. // 1.1. GET: purchase price (purchase) // 1.2. GET: interest rate (apr) // 1.2.1. SET: apr = apr / 100.0 // 1.3. GET: minimum payment percentage (fraction) // 1.3.1. SET: fraction = fraction / 100.0 // 1.4. GET: minimum absolute payment (abs_minimum_pmt) // // 2. TASK: Generate a Month-by-Month Table until item is paid off. // 2.1. TASK: Output Table Header (first row of table) // 2.2. TASK: Initialize variables for first month // 2.2.1. SET: month = -1 (i.e., month prior to "month 0") // 2.2.2. SET: new_balance = 0.0 // 2.2.3. SET: minimum_due = 0.0 // 2.3. TASK: Initialize variable for running totals // 2.3.1. SET: TotalFinanceCost = 0.0 // 2.3.2. SET: TotalCost = 0.0 // 2.4. WHILE (balance > 0) // 2.4.1. TASK: Update variables for that month's activity // 2.4.1.1. SET: month++ // 2.4.1.2. SET: old_balance = new_balance // 2.4.1.3. SET: interest = old_balance * apr * (1.0/12.0) // 2.4.1.4. SET: payment = minimum_due // 2.4.1.5. SET: new_balance = old_balance + interest - payment // 2.4.1.6. TASK: Set Minimum Payment // 2.4.1.6.1. IF: (new_balance > abs_minimum_pmt) // 2.4.1.6.1.1. SET: minimum_due = new_balance * fraction // 2.4.1.6.1.2. IF: (minimum_due < abs_minimum_pmt) // 2.4.1.6.1.2.1. SET: minimum_due = abs_minimum_pmt // 2.4.1.6.2. ELSE: // 2.4.1.6.2.1. SET: minimum_due = new_balance // 2.4.2. TASK: Update running totals // 2.4.2.1. TotalFinanceCost += interest // 2.4.2.2. TotalCost += payment // 2.4.3. TASK: Print out activity for that month // 2.4.3.1. OUT: month // 2.4.3.2. OUT: old_balance // 2.4.3.3. OUT: interest // 2.4.3.4. OUT: payment // 2.4.3.5. OUT: new_payment // 2.4.3.6. OUT: minimum_due // // 3. TASK: Generate a Final Summary after the item is paid off. // 3.1. OUT: Number of months (month) // 3.2. OUT: Purchase Price (purchase) // 3.3. OUT: Total Finance Charges (TotalFinanceCost) // 3.4. OUT: Total Cost (TotalCost)