Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Student Loan Program. Prompt for 1) an initial loan amount, 2) the annual percen

ID: 3632800 • Letter: S

Question

Student Loan Program. Prompt for 1) an initial loan amount, 2) the annual
percentage rate, and 3) the desired monthly payments. Print out a repayment schedule with at
least 4 columns: the month, month’s beginning balance, current months interest, and total paid.
Add text column headings at the top of the chart. Output the correct last payment amount
and the total interest paid. (The special character ‘ ’, tab, can be used to align output columns)
current_months_interest = (beginning_balance * annual_percentage_rate) / ( 12 * 100)
beginning_balance = beginning_balance - ( payment – current_months_interest)
This problem should use floating point arithmetic. There are three levels of this program.
1) Basic (max score=90): a) floating point arithmetic and whole dollar amounts.
b) Results displayed in whole dollars
2) Intermediate (max score=95): a) floating point arithmetic and dollar amounts in cents.
b) Displayed in whole dollars
3) Advanced (max score=100): a) Same as intermediate, but
b) results displayed in dollars and cents format

Explanation / Answer

file "abc.c" .section .rodata .align 4 .LC0: .string "Please enter 1 to 5 (please hit enter after entering each number) " .LC1: .string "%d" .align 4 .LC2: .string "Please enter 40 to 45 (please hit enter after entering each number) " .LC3: .string "C[%d] = %d , " .text .globl main .type main, @function main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $112, %esp movl $.LC0, %eax movl %eax, (%esp) call printf movl $0, 108(%esp) jmp .L2 .L3: movl $.LC1, %eax leal 104(%esp), %edx movl %edx, 4(%esp) movl %eax, (%esp) call __isoc99_scanf movl 108(%esp), %eax movl 104(%esp), %edx movl %edx, 84(%esp,%eax,4) addl $1, 108(%esp) .L2: cmpl $4, 108(%esp) jle .L3 movl $.LC2, %eax movl %eax, (%esp) call printf movl $0, 108(%esp) jmp .L4 .L5: movl $.LC1, %eax leal 104(%esp), %edx movl %edx, 4(%esp) movl %eax, (%esp) call __isoc99_scanf movl 108(%esp), %eax movl 104(%esp), %edx movl %edx, 60(%esp,%eax,4) addl $1, 108(%esp) .L4: cmpl $5, 108(%esp) jle .L5 movl $10, 20(%esp) movl $20, 24(%esp) movl $30, 28(%esp) movl $40, 32(%esp) movl $50, 36(%esp) movl $60, 40(%esp) movl $70, 44(%esp) movl $80, 48(%esp) movl $90, 52(%esp) movl $100, 56(%esp) movl $0, 108(%esp) jmp .L6 .L7: movl 108(%esp), %eax leal 1(%eax), %edx movl 108(%esp), %eax movl 84(%esp,%eax,4), %eax movl 60(%esp,%eax,4), %eax movl %eax, 20(%esp,%edx,4) addl $1, 108(%esp) .L6: cmpl $4, 108(%esp) jle .L7 movl $0, 108(%esp) jmp .L8 .L9: movl 108(%esp), %eax movl 20(%esp,%eax,4), %edx movl $.LC3, %eax movl %edx, 8(%esp) movl 108(%esp), %edx movl %edx, 4(%esp) movl %eax, (%esp) call printf addl $1, 108(%esp) .L8: cmpl $9, 108(%esp) jle .L9 leave ret .size main, .-main .ident "GCC: (Ubuntu 4.4.3-4ubuntu5) 4.4.3" .section .note.GNU-stack,"",@progbits