Java Reference
In-Depth Information
payment consists of the interest on the loan and the payment toward the
principal amount. To be specific, suppose that you borrow $1000 at the
interest rate of 7.2% per year and the payments are monthly. Suppose that
your monthly payment is $25. The interest is 7.2% per year and the payments
are monthly, so the interest rate per month is 7.2/12 ¼ 0.6%. The first month's
interest on $1000 is 1000 * 0.006 ¼ 6. Because the payment is $25 and
interest for the first month is $6, the payment toward the principal amount
is 25 - 6 ¼ 19. This means that after making the first payment, the loan
amount is 1000 - 19 ¼ 981. For the second payment, the interest is calculated
on $981. So the interest for the second month is 981 * 0.006 ¼ 5.886, that is,
approximately $5.89. This implies that the payment toward the principal is
25 - 5.89 ¼ 19.11, and the remaining balance after the second payment is
981 - 19.11 ¼ 961.89. This process is repeated until the loan is paid. Write a
program that accepts as input the loan amount, the interest rate per year, and
the monthly payment. (Enter the interest rate as a percentage. For example, if
the interest rate is 7.2% per year, then enter 7.2.) The program then outputs
the number of months it would take to repay the loan. (Note: If the monthly
payment is less then the first month's interest, then after each payment, the
loan amount will increase. In this case, the program must warn the borrower
that the monthly payment is too low and with this monthly payment the loan
amount could not be repaid.)
20. Enhance your program of Exercise 19, by first telling the user the minimum
monthly payment and then prompting the user to enter the monthly payment.
The last payment might be more than the remaining loan amount and interest on
it. In this case, output the loan amount before the last payment and the actual
amount of the last payment. Also, output the total interest paid.
21. Write a program that reads in a line consisting of a student's name, Social
Security number, user id, and password (separated by one space). The
program outputs the string in which all the digits of the Social Security
number and all the characters in the password are replaced by x . (The Social
Security number is in the form 000-00-0000 . The student name does not
contain any digits, and the user id and the password do not contain any
spaces.) Use the appropriate string methods described in Table 3-1.
22. Write a complete program to generate the pattern given in Example 5-19.
23. Write a complete program to generate the multiplication table given in
Example 5-20.
24. Write a complete program to process the data given in Example 5-21.
25. Write a complete program to process the data given in Example 5-22.
26. You have been given the contract for making little conical cups that are used
for bottled water. These cups are to be made from a circular waxed paper die
Search WWH ::




Custom Search