Question: Consider the following Credit Card class that defines credit card objects modeling a simplified version of traditional credit cards. They store information about the

Consider the following Credit Card class that defines credit card objects modeling

 a simplified version of traditional credit cards. They store information about the

Consider the following Credit Card class that defines credit card objects modeling a simplified version of traditional credit cards. They store information about the customer, issuing bank, account identifier, credit limit, and current balance. 1 public class Credit Card { // Instance variables: 3 private String customer, 4 private String bank, private String account; private int limit; 5 protected double balance; 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 // Constructors: public Credit Card (String cust, String bk, String acnt, int lim, double initial Bal) { customer = cust: bank = bk; account - acnt: limit - lim; balance - initialBal; name of the customer (eg. "John Bowman") name of the bank (eg. "California Savings") account identifier (eg "5391 0375 9387 5309") // credit limit (measured in dollars) // current balance (measured in dollars) } public Credit Card(String cust, String bk, String acnt, int lim) { this(cust, bk, acnt, lim, 0.0): } // Accessor methods: public String getCustomer() { return customer; } public String getBank() { return bank; } public String getAccount() { return account; } public int get Limit() { return limit; } public double getBalance() ( return balance; } // Update methods public boolean charge(double price) { if (price + balance > limit) return false; //at this point, the charge is successful balance += price, return true; // use a balance of zero as default } // Utility method to print a card's information // make a charge // if charge would surpass limit // refuse the charge // update the balance } public void makePayment(double amount) { // make a payment balance amount: 42 43 44 // main method shown on next page... 45 ) announce the good news public static void printSummary(Credit Card card) { System.out.println("Customer " + card.customer); System.out.println("Bank = "+ card.bank); + card.account); System.out.println("Account System.out.println("Balance + card.balance); // implicit cast System.out.println("Limit="+ card.limit); // implicit cast CSC 311 Data Structures 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 public static void main(String[] args) { Credit Card [] wallet = new Credit Card [3]; wallet [0] = new Credit Card("John Bowman", "California Savings", "5391 0375 9387 5309", 5000); wallet [1] = new Credit Card ("John Bowman", "California Federal", "3485 0399 3395 1954", 3500); wallet[2] = new Credit Card ("John Bowman", "California Finance", "5391 0375 9387 5309", 2500, 300); for (int val=1; val 200.0) { } } // calling static method card.makePayment(200); System.out.println("New balance = " + card.getBalance()); Here is your task: 1. Explain the purpose of the five declared instance variables. Why are some of them declared as private and the others as protected? 2. Describe the constructors used in this class. What is the meaning and purpose of the this keyword? 3. Explain the functionality of the accessors and update methods. 4. What is the purpose of the static method? What will happen if the static reserved word is omitted? 5. Consider the main method. What is the data structure used for storing a number of credit card accounts? 6. Add two operations of your choice on the declared credit card accounts. 7. Characterize the output operations used in the above code. Provide a few examples of other possible output functions. 8. Set up an IDE such as Eclipse (or any other Java software you might be familiar with) and run this code, or its smaller version. 9. Provide the screenshots of the CreditCard code running. 10. List the names of the data structures used in this code. Keep your answers short but substantive. Submit to Blackboard by Wednesday, Feb. 9, 11:59pm.

Step by Step Solution

3.53 Rating (146 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The five instance variables are customer bank account limit and balance They represent the customers ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!