Consider the following Credit Card class that defines credit card objects modeling a simplified version of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 <= 16; val++) { wallet[0].charge(3*val); wallet [1].charge (2*val); wallet [2].charge(val); } for (Credit Card card: wallet) { Credit Card.printSummary(card); while (card.getBalance() > 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. 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 <= 16; val++) { wallet[0].charge(3*val); wallet [1].charge (2*val); wallet [2].charge(val); } for (Credit Card card: wallet) { Credit Card.printSummary(card); while (card.getBalance() > 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.
Expert Answer:
Answer rating: 100% (QA)
The five instance variables are customer bank account limit and balance They represent the customers ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
(20 points)Write a program that prompts the user to input five decimal numbers. The program should then add the five decimal numbers, convert the sum to the nearest integer, and print the result....
-
1. An interceptor missile system meant for area denial to enemy aircraft has a 4kg warhead. The engine has an Isp of 235 seconds and needs to develop a DELTA V of 750m/s with only 10kg of solid fuel...
-
Assume that you are purchasing shares in a company in the variety store and gas bar supply business. Suppose you have narrowed the choice to BFI Trading Ltd. and Lin Corp. and have assembled the...
-
Philip Morris has issued bonds that pay annually with the following characteristics: a. Calculate modified duration using the information above. b. Explain why modified duration is a better measure...
-
Mrs Jones booked an international ticket to Dubai with one of our consultants. The consultant charged Mrs Jones R 1 0 , 0 0 0 for the ticket and the cost of the ticket was R 9 0 0 0 . Mrs Jones did...
-
Which of the following is not a control activity? a. Mandatory vacations b. Risk assessment C. Security measures d. Proper authorization
-
Multiple-Choice Questions 1. The key difference between residual income and economic value added is that EVA a. Uses the actual cost of capital for the company rather than a minimum required cost of...
-
Healthcare organizations involve a wide variety of departments, such as the following. Pharmacy HR Medical Billing OBGYN Emergency Pediatrics ICU Maintenance IT Surgery Gift Shop
-
The steam cycle of a marine nuclear propulsion plant may be modeled as an ideal Rankine cycle. a . Using the information provided below determine the enthalpy of the working substance in each state....
-
A machine costing $900,000 with a five-year useful life and a $90,000 salvage value is installed in the factory on January 1. The factory manager estimates the machine will produce 24,000 units of...
-
Solve ( 3 x - 1 ) 2 - 1 = 2 4
-
Explore the evolutionary processes that lead to enzyme diversification and adaptation. What role do gene duplication and convergent evolution play in the evolution of enzyme functions ?
-
What is the wavelength of an x - ray photon with energy 1 0 keV ( 1 0 , 0 0 0 eV ) ? What is its frequency?
-
The stock of Sedly Inc. is expected to pay the following dividends. Year 1 2 3 4 Dividend $2.30 $3.50 $1.75 $2.20 At the end of the fourth year its value is expected to be $37.70. What should...
-
A sound wave has a speed of 3 8 0 meter / second in some gas. There is a source of waves with a frequency of 6 7 0 hertz, the source is not moving. There is an observer moving towards the source, the...
-
0. Market demand is the: Sum of all individual demands for a product in a given time period. Satisfaction from consuming an additional unit of a good. Same thing as an individual's demand. Sum of all...
-
14. In testing the existence assertion, an auditor ordinarily works from the a. Financial statements to the accounting records. b. General journal to the general ledger. c. Supporting evidence to the...
-
Suppose that you have declared an array as follows: num values[4] = 0, 0, 0, 0. Which of the following is an allowed operation? a. values[2] = 17 b. input values[0] c. values[3] = values[0] + 10 d....
-
Your downloadable files for Chapter 9 include a file named DEBUG09-04.jpg that contains a flowchart with syntax and/or logical errors. Examine the flowchart, and then find and correct all the bugs.
-
In most modern programming languages, the highest subscript you should use with a 12-element array is ____________. a. 10 b. 11 c. 12 d. 13
-
The following data are taken from the comparative balance sheets of Girard Billiards Club, which prepares its financial statements using the accrual basis of accounting. Fees are billed to members...
-
Colin Mochrie Company has the following balances in selected accounts on December 31, 2008. All the accounts have normal balances. Colin Mochrie Company debits prepayments to expense accounts when...
-
Tony Masasi started his own consulting firm, Masasi Company, on June 1, 2008. The trial balance at June 30 is shown. In addition to those accounts listed on the trial balance, the chart of accounts...
Study smarter with the SolutionInn App