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 but if the previous balance was greater than 0 the interest is 2% of the total owed (previous balance plus additional charges).

Respuesta :

Answer:

import java.util.*;

import java.text.*;

class CreditCardBill

{

public static void main(String[] args)

{

Scanner sc = new Scanner(System.in);

NumberFormat defaultFormat = NumberFormat.getCurrencyInstance(Locale.US);

System.out.println("CS Card International Statement");

System.out.println("===============================");

System.out.print("Previous Balance: $");

double prevBalance = sc.nextDouble();

System.out.print("Additional Charges: $");

double addCharges = sc.nextDouble();

double interest;

if(prevBalance == 0)

interest = 0;

else

interest = (prevBalance + addCharges) * 0.02;

System.out.println("Interest: "+defaultFormat.format(interest));

double newBalance = prevBalance + addCharges + interest;

System.out.println("New Balance: "+defaultFormat.format(newBalance));

double minPayment;

if(newBalance < 50)

minPayment = newBalance;

else if(newBalance <= 300)

minPayment = 50.00;

else

minPayment = newBalance * 0.2;

System.out.println("Minimum Payment: "+defaultFormat.format(minPayment));

}

}