This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: In Java, use the power function for this formula (although your variable names must be more meaningful): M = P * J / (1 (Math.pow( 1 + J , -N ))) The total cost of the loan is simply the monthly payment * length of the loan in months Output (sample program run with output follows on next page): Display interest rate to three decimal places Display monetary amounts to two decimal places, and separate thousands with a comma You may set up columns with printf or use tab (\t between columns NOTE: If some of your amounts differ from those shone below by 1 penny, that is ok. The difference lies in when the rounding to decimal places occurred, and may vary slightly. run: Enter loan amount: 10000 Enter number of years: 5 Interest Rate Monthly Payment Total Payment 5.000 188.71 11,322.74 5.125 189.28 11,357.13 5.250 189.85 11,391.59 5.375 190.43 11,426.11 5.500 191.01 11,460.69 7.875 202.16 12,129.97 8.000 202.76 12,165.83...
View Full Document
- Spring '08
- Computer Programming