Computing a Charge Account Statement

Write a program, Charge.java, to prepare the monthly charge account statement for a customer of CS CARD International, a credit card company. The program should take as input from the user the previous balance on the account and the total amount of additional charges during the month. These values may be decimals (e.g. 22.52), but the user will not provide a dollar sign character ('$'). The program should then compute the interest for the month, the total new balance (which will be the previous balance, plus additional charges, plus interest), and the minimum payment due.

You should assume the interest is 0% if the previous balance was 0, but if the previous balance was greater than 0, the interest is 2% of the total owed (i.e., the previous balance plus the additional charges--nasty! I suggest getting a different credit card!).

You should assume the minimum payment is defined as follows (again, new balance, is the previous balance on the account plus the additional during the month):

newBalance Minimum Payment
less than $50 the entire newBalance
$50 or more, but not more than $300 $50
more than $300 20% of newBalance

 

So if the new balance is $38.00 then the person must pay the whole $38.00; if the balance is $128 then the person must pay $50; if the balance is $350 the minimum payment is $70 (20% of 350). The program should print the charge account statement in the format below. (Notice the blank lines.) Print the actual dollar amounts in each place using printf so that there are always two decimal places, and the decimal points line up. (When you cut and paste your output into your lab document you'll have to use a monospace font, such as Courier, to get the decimal places properly aligned.)

Here's sample output (not showing the user's input):

         CS CARD International Statement
         ===============================

         Previous Balance:      $  20.00
         Additional Charges:    $ 131.50
         Interest:              $   3.03

         New Balance:           $ 154.53
 
         Minimum Payment:       $  50.00

You may assume that the user will never enter any values such that the the newBalance is greater than $9999.

I'm not giving you a code template here; you'll have to design the structure of the class from scratch. Name the class Charge. Take the time to think through how the program should work. First, get the input needed from the user. Next, calculate the financial stuff. Third, generate the output.

Move from Small Victory to Small Victory!

I suggest you solve the problem in steps--don't try to do it all at once! One path to the final solution would be this sequence of steps:

  1. First, get the program to print only the Previous Balance and Additional Charges (i.e., the values the user provides via nextFloat(). Test it with multiple values.
  2. Then get the program to also print the Interest. Again, test with multiple values, satisfying yourself that the interest is being correctly calculated.
  3. Add the New Balance output.
  4. Add the Minimum Payment output.

At each step, run your program a few times, using values that are near or equal to where behaviors should change to make sure the program is working correctly. For example, does the program work properly for $49.99, $50.00, and $50.01?

Provide a hardcopy of your code, plus the transcript of the program running on at least three different inputs, showing the three possible minimum charge calculations.