15-110 FALL 2009 (CORTINA)

PROGRAM 1 - due Tuesday, September 8, 2009 by 11:59PM

Electronic handin will be available after 5PM on Thursday.

TC Bank has hired you to create a program to compute the final value of a certificate of deposit for a customer. In this account, the customer deposits some initial amount (D) and then leaves the money in the account for exactly one year. During this year, the account earns an annual rate of compounded interest of I. The number of times per year that the account earns interest is given by n. The final amount in the certificate of deposit at the end of the year based on the information above is given by the formula:

F=D(1+I/N)^N

For example, customer Andrew Carnegie opens a certificate of deposit with $15110.00 for exactly one year with an interest rate of 6% "compounded monthly". The phrase "compounded monthly" means that interest is earned every month, or 12 times per year. This means that D = 15110.00, I = 0.06 and N = 12. Based on the formula above, Carnegie would have an account with approximately $16041.95 at the end of one year.

Assignment

Write a simple Java program in a project named Program1 that contains one class named InterestCalculator that computes and displays the final amount in a certificate of deposit for one year given the initial deposit, annual interest rate and number of interest payments per year.

Program Requirements

Your InterestCalculator class must have two methods as described below.

  1. Write a static method named displayBanner that prints out the following banner:

    ************************************** 
       TC BANK - CERTIFICATE OF DEPOSIT 
    ************************************** 
    

  2. Write a main method that does the following:

    1. Prompt the user to input the initial amount deposited, the annual interest rate and the number of times/year that interest is paid to the acccount, one at a time. After each prompt, read in the required value from the keyboard using a Scanner object. NOTE: You only have to declare one Scanner object for the entire program. You can use it to read in all three values. Store each of the input values in a reasonably named variable of an appropriate type. Do not use variable names like D, I, etc.

    2. Using the variables you declared above, compute the final amount for the certificate of deposit account. Display the bank banner by calling the displayBanner method you wrote and then display the data you read in and the final amount in the account (see examples below). For maximum credit, display your final amount accurate to two decimal places.

      NOTE: If the monetary value ends in 0 cents (e.g. $15110.00), this can be output without the extra 0, ($15110.0 is ok).

Sample Output

Your output should be displayed as shown in the following examples, using your displayBanner method to print the banner. Depending on how you do your calculation, your results may differ slightly from the result shown below. Look at the samples to determine the appropriate types for each variable you need.

Here are 4 separate runs of the program (user input shown in italics):

Please input the initial deposit: 15110.00
Please input the interest rate as a percentage: 6.0
Please input the number of interest payments per year: 12

**************************************
   TC BANK - CERTIFICATE OF DEPOSIT
**************************************
Initial Deposit: $15110.0
Interest Rate: 6.0%
Number of Interest Payments: 12
Final Amount: $16041.95


Please input the initial deposit: 4321.00
Please input the interest rate as a percentage: 5.5
Please input the number of interest payments per year: 365

**************************************
   TC BANK - CERTIFICATE OF DEPOSIT
**************************************
Initial Deposit: $4321.0
Interest Rate: 5.5%
Number of Interest Payments: 365
Final Amount: $4565.29


Please input the initial deposit: 123.45
Please input the interest rate as a percentage: 7.0
Please input the number of interest payments per year: 4

**************************************
   TC BANK - CERTIFICATE OF DEPOSIT
**************************************
Initial Deposit: $123.45
Interest Rate: 7.0%
Number of Interest Payments: 4
Final Amount: $132.32


Please input the initial deposit: 10000.00
Please input the interest rate as a percentage: 12.0
Please input the number of interest payments per year: 1

**************************************
   TC BANK - CERTIFICATE OF DEPOSIT
**************************************
Initial Deposit: $10000.0
Interest Rate: 12.0%
Number of Interest Payments: 1
Final Amount: $11200.0

Compiling and Testing

Compile and test that your program runs correctly. If your program does not compile and run, you will not receive full credit for your assignment.

What happens if your program asks for a double value and you input an integer? What happens if your programs asks for an int value and you input a floating point value? Add a comment to your program to explains what happens and why this makes sense.

Make sure you add a comment at the beginning of your program with your name, andrew id, and section.

Hand-in Instructions

See the course website for instructions on how to hand in your program. Remember that the work you submit must be your own. Also, late hand-ins are not accepted. Please plan ahead and submit early to avoid server overload at the deadline. The deadline is based on the server's clock, not your clock. Please do not email your code to your instructor or course assistant as your official hand-in; these will not be graded.