You are on page 1of 1

ECE429 Program 1 Date: 7/1/13, Monday, week 2 Due Date: 7/15/13, Monday, week 4 Total Points: 22 points Turn

in this to Program 1 folder. 1. (5%) Write a Java program that reads an integer from keyboard and display the sum of the digits of this integer. For example, if you input 429, the output should be 4+2+9 = 15. Test for at least 3 other integers. Do not confuse this question with the sum of two integers.

2. (5%) Write a Java program that reads an integer, a base picked by you (base 2 means binary, base 8 means octal etc.) and display this integer converted from base 10 to that base (for example, 429 in base 8 is 655 8 (can be verified since 6 * 64 + 5 * 8+ 5 = 384 + 40 + 5 = 429), 429 in base 2 is 110101101). Do not use Java provided class or method to convert base automatically. Your program should support base 2, base 8, and base 16. What is 429 in hex? Test your program with 3 different integers and base 2, 8, and 16. 3. (12%) Mortgage Calculation Enhance mortgage.java covered in the class so that (a) Given principal, annual interest rate, and terms of the loan in years , you compute the monthly payment, total payment, and also total interest payment. Test your program for principal $100,000, rate 6%, 30 years as demonstrated in the class, plus three more examples. For example, the same principal $100,000 for different rates like 5%, 4%, 10%, 12%, different periods like 15 years, 40 years, 20 years etc. A professional way is to put the outputs in tables. (b) With the loan balance, the interest rate, and monthly payment, what would be the remaining number of months to pay off like what you see in the finance.yahoo.com page http://finance.yahoo.com/loans or the more current web page of Yahoo? Derive the formula for this part and show in the word document how you derive the formula. (c) With the formula you derive in (b), write the code to compute the remaining number of months given loan balance, interest rate and monthly payment. For example, with loan balance $100K, rate 6%, and monthly $600 (close to $599.55), your program should compute 360 months or 359.some months. Test your program with a few other balances like $80K, $60K (or different payment, different rate etc.).

You might also like