/* Java applet that determine if a customer has exceeded the credit limit on a charge account */ import javax.swing.*; import java.awt.*; public class CreditCheckApplet extends JApplet { int actNo = 0; double initB = 0.0; double charges = 0.0; double credits = 0.0; double creditLimit = 0.0; String limit = ""; public void init () { /* define variables int actNo ---account number; double initB ---initial balance at the beginning of a month double charges ---total of all items charged by the customer this month. double credits --total of all credits applied to the customer's account this month double creditLimit --allowed credit limit CreditCheck myCreditCheck --User defined data type CreditCheck used for credit checking */ int actNo = 0; String CName; //Added variable double initB = 0.0; double charges = 0.0; double credits = 0.0; double creditLimit = 0.0; CreditCheck myCreditCheck = null; // get input actNo = Integer.parseInt (JOptionPane.showInputDialog ("Enter the account number:")); CName = (JOptionPane.showInputDialog ("Enter the customer name.")); // gathered info for added variable initB = Double.parseDouble (JOptionPane.showInputDialog ("Enter the initial balance:")); charges = Double.parseDouble (JOptionPane.showInputDialog ("Enter the total charges:")); credits = Double.parseDouble (JOptionPane.showInputDialog ("Enter the total payments:")); creditLimit = Double.parseDouble (JOptionPane.showInputDialog ("Enter the credit limit:")); // initialize myCreditCheck object from CreditCheck class construction using 'new' operator myCreditCheck = new CreditCheck (); myCreditCheck.setCustomerName (CName); myCreditCheck.setAccountNumber (actNo); myCreditCheck.setInitialBalance (initB); myCreditCheck.setTotalCharges (charges); myCreditCheck.setTotalCredits (credits); myCreditCheck.setCreditLimit (creditLimit); myCreditCheck.showResult (); } }