Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Bartleby Related Questions Icon
Related questions
Question
C programming
Transcribed Image Text:Expert Q&A
Done
2) Implement this C program using at least three arrays to store the interest, principle
and balance for each payment respectively. For example, interest[0] stores the paid
interest in the first payment. Name this C program as loanCalcArr.c.
3) Implement this C program using at least three arrays to store the interest, principle
and balance after each payment respectively. For example, interest[0] stores the paid
interest in the first payment. Besides, please use three pointers to visit the element in
the three arrays separately. Name this C program as loanCalcPtr.c.
4) Implement this C program by defining a structure for each payment. The structure
should have at least three members for the interest, principle and balance separately.
And store all the payments in a structure array (the max size of which could be 100).
Name this C program as loanCalcStruct.c
In this C program, the input and output are defined as following:
Input: amount of loan, interest rate per year and number of payments
• Output: a table of amortization schedule (also called payment schedule) containing
payment number, monthly payment, principal paid, interest paid and new balance at
each row.
The attached screenshot below shows a sample of the output.
Yuans-MacBook-Pro:PC yuanlong$ ./loanCalc
Enter amount of loan : $ 500
Enter Interest rate per year : % 7.5
Enter number of payments : 5
Montly payment should be 101.88
F======== AMORTIZATION SCHEDULE======
Principal
98ドル.76
99ドル.38
100ドル.00
100ドル.62
101ドル.25
%3== ======
Рауment
101ドル.88
101ドル.88
101ドル.88
101ドル.88
101ドル.88
Interest
3ドル.12
2ドル.51
1ドル.89
1ドル.26
s0.63
Balance
401ドル.24
301ドル.87
201ドル.87
101ドル.25
0ドル.00
14
15
Note:
• monthly payments are equal. The way to calculate monthly payment and other values
for each row are provided in Appendix.
The C program can be implemented within 80 lines of code. If your program is longer
than 80 lines, you may need to think about how to simplify your program.
Hint: To print out a percentage %, please use %%. You may need to use C math library to
calculate the powers of numbers. To compile a C program using math library, you must add
option Im at the end of the cc command to link math library. E.g. gcc -o test test.c -Im
1. Calculating the monthly payment.
(Note: The following instruction is from
http://www.vertex42.com/ExcelArticles/amortization-calculation.html )
The formula for calculating the payment amount is shown below.
r(1 +r)"
A = B
(1+r)" – 1
where
A = payment Amount per period (monthly payment)
B = initial Balance (loan amount)
• r= interest rate per period
n = total number of payments or periods
Example 1: What would the monthly payment be on a 5-year, 20,000ドル car loan with a
nominal 7.5% annual interest rate?
B = 20,000ドル
r= 7.5% per year / 12 months = 0.625%= 0.00625 per period
n = 5 years 12 months = 60 total periods
A = 20000 .
000625 (1+0.00625 )= 400,76
(1+0.00625 40-1
2. Calculating the Principal(P), Interest(INT) and Balance(B) for each
payment.
The formula is shown below.
INT(n) = B(n – 1) •r;
P(n) = A - INT (n);
B(n) = B(n – 1) - P(n);
Where INT (n), P(n) and B(n) are the paid principal, paid interest and new balance for the
nth payment. And B(0) means the loan amount.
Expert Solution
Check MarkThis question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
bartleby
This is a popular solution
bartleby
Trending nowThis is a popular solution!
bartleby
Step by stepSolved in 2 steps with 2 images
Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
Recommended textbooks for you
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education