JamesMadisonUniversity

Computer Science Department


CS 139 Lab:A Charge Account Statement


Objectives:

After this lab, students will be able to use a java if/else statement and either nested if statements or compound conditions.

Background:

CS Card International is a credit card company which produces charge statements for its customers each month. This program will generate the appropriate statement amounts.

New Terms:

No new terms in this lab.

Materials:

NOTE: submit system files are available for this lab.
Use this program as a starter. CSCard.java Variables and output to match the statement below have been defined as well as the input prompts.
Acknowledgment Adapted from a lab from the original textbook for the course.

A Setting up your environment

  1. Create a new folder for this lab.
  2. Download a copy of CSCard.java to your folder.
  3. Edit the program following the methodology and instructions below.  NOTE: The output has been set up in submit.  Keep all output statements exactly as you see them here.

B Overall Instructions:

Write a program to prepare the monthly charge account statement for a customer of CS CARD International, a credit card company. The program should take as input the previous balance on the account and the total amount of additional charges during the month. The program should then compute the interest for the month, the total new balance (the previous balance plus additional charges plus interest), and the minimum payment due.

Assume the interest is 0 if the previous balance was $0.00 or less.  If the previous balance was greater than 0 the interest is 2% of the total owed (previous balance plus additional charges). 

Calculate the minimum payment based on the table below:

            $0.00             for a new balance less than $0
new balance for a new balance between $0 and $49.99 (inclusive)
$50.00 for a new balance between $50 and $300 (inclusive)
20% of the new balance for a new balance over $300

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. Print all amounts using the currency format.  (NOTE: formatting has been done for you.  Use the variables provided and keep all output statements exactly as in the .java file.

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

Previous Balance: $
Additional Charges: $
Interest: $

New Balance: $

Minimum Payment: $

C Steps

  1. Make sure you understand how the calculations are done yourself before trying to program. Write the algorithm and test your algorithm with some data to see how it works.  Use at least four different examples to use for testing.  You want to be able to test each of the conditions shown above.
  2. Using the variables provided, code the input statements as described in the .java file.  You must insure that the program will not crash if the user enters a bad value.
  3. Write some temporary output statements to show you the value that is read in.
  4. For each calculation (interest, new balance and total), you should code that piece and use an ouput statement to make sure that the calculation was done correctly.
  5. When you have the minimum payment coded, test the program with a variety of data. Include debit balance, credit balance, and 0 balance. Make sure that you test each of the branches of your if statement(s) and the boundary conditions (like 0 and 49.99).

D Submission

Submit your program using the Linux submit mechanism. Updated 10/12/10.