CSCard - // compute minimum payment if (newBalance...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// ************************************************************************ // CSCard.java // // Determines the interest, new balance and minimum payement for a credit // card when given the previous balance and new charges. // // ************************************************************************ import java.util.Scanner; import java.text.NumberFormat; public class CSCard { public static void main(String[] args) { double prevBalance; double newCharges; double interest, newBalance, minPayment; Scanner scan = new Scanner (System.in); System.out.print("Enter the previous balance: "); prevBalance = scan.nextDouble(); System.out.print("Enter the total new charges: "); newCharges = scan.nextDouble(); // compute interest at 2% if (prevBalance == 0) interest = 0; else interest = 0.02 * (prevBalance + newCharges); // compute new balance newBalance = prevBalance + newCharges + interest;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: // compute minimum payment if (newBalance < 50) minPayment = newBalance; else if (newBalance <= 300) minPayment = 50; else minPayment = newBalance * 0.2; // print results NumberFormat money = NumberFormat.getCurrencyInstance(); System.out.println("\tCS CARD International Statement"); System.out.println("\t==============================="); System.out.println(); System.out.println("\tPrevious Balance:\t" + money.format(prevBalance)); System.out.println("\tAdditional Charges:\t" + money.format(newCharges)); System.out.println("\tInterest:\t\t" + money.format(interest)); System.out.println(); System.out.println("\tNew Balance:\t\t" + money.format(newBalance)); System.out.println(); System.out.println("\tMinimum Payment:\t" + money.format(minPayment)); } }...
View Full Document

Page1 / 2

CSCard - // compute minimum payment if (newBalance...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online