Question: Write a C program to read loan data ( principal , interest rate, period ) , and compute monthly payment, total payment, monthly balance. First
Write a C program to read loan data principal interest rate, period and compute monthly payment, total payment,
monthly balance. First type and run the program to make sure everything works. Then replace two boxes with two functions:
Line with one valuereturning function.
Lines with void function to compute items needed.
No global variable can be used!
#include
int main
float principal; loan principal
float annualintrate; annual interest rate
float monintrate; monthly interest rate
int numofyears; loan period in years
int numofmonths; loan period in months
float monpmt; monthly payment
float totalpmt; total patment paid over the loan years
float tointerest; interest amount of monthly payments
float toprincipal; amount of monthly payment deducted from loan balance
float balance; monthly balance
prompt and read loan components
printf
enter principal,, annual inteerest rate and load period, in years: ;
scanfsf f d &principal, &annualintrate, &numofyears;
calculating monthly and total payment
monintrate annualintrate ;
numofmonths numofyears ;
monpmt principal monintrate; pow monintrate, numofmonths
totalpmt monpmt numofmonths;
printing results
printf
;
printfPrincipal f
principal;
printfAnnual interest rate f
annualintrate;
printfYears of loan d
numofyears;
printfMonthly Payment f
monpmt;
printfTotal payment f
totalpmt;
printf
;
calculate loan balance for months
the header must be printed before the loop
printfMonth to interest to principal Balance
;
printf
;
balance principal; original balance: entire loan
for intmonnum ; monnum ; monnumthe forrloop and printing must stau in their own current place. do not move them to insdide function.
tointerest balance monintrate; amount of loan used for interest
toprincipal monpmt tointerest; amount of loan that reduces balance
balance toprincipal; adjust balance
printfd f f f
monnum, tointerest, toprincipal, balance;
output
enter principal, annual interest rate and load period, in years:
principal
annual interest rate
years of loan
monthly payment
total payment
month to interest to principal balance
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
