Data Structures and Algorithms in Java
Data Structures and Algorithms in Java
6th Edition
ISBN: 9781118771334
Author: Michael T. Goodrich
Publisher: WILEY
Expert Solution & Answer
Book Icon
Chapter 2, Problem 20C

Explanation of Solution

Initial consideration:

There is a need to provide the modified version of theCreditCard class given in the code fragment 1.5 in the text book that contains

  • TheCreditCard class description needs to be modified in such a way that a customer is allocated a minimum monthly payment in the form of percentage of the balance.
  • The modified CreditCard class should also have the getBalance( ) methodas well to check the balance for a particular customer.

Modified version of CreditCard class:

The CreditCard class has to be modified that need to be referthe code fragment 1.5 given in the textbook which contains the CreditCardclass. This code is modified with the little change as follows.

  • Anew instance variable balance is used thathas private visibility, but a new protected method isadded, with signature setBalance(newBalance) to get the new updated balance for that particular customer.
  • Also the modified code has shown to implement the method called PredatoryCreditCard.processMonth()as follows:

Modified code:

//Class definition

public class CreditCard

{

  // Instance variables:

  private String customer; // name of the customer

  private String bank; // name of the bank

  private String account; // account identifier

  private int limit; // credit limit

  protected double newbalance;//The new updated balance

  protected double balance; // current balance

  // Constructors:

public CreditCard(String cust, String bk, String acnt, int lim, double initialBal)

  {

  customer = cust;

bank = bk;

account = acnt;

limit = lim;

//balance has private visibility

Private int balance = initialBal;

  }

public CreditCard(String cust, String bk, String acnt, int lim)

{

  // use a balance of zero as default

  this(cust, bk, acnt, lim, 0.0);

  }

  // New Accessor method

  public PredatoryCreditCard...

Blurred answer
Students have asked these similar questions
Answer the given question with a proper explanation and step-by-step solution. USING JAVA: ---Sorting the Invoices via dates--- Another error that will still be showing is that there is not Comparable/compareTo() method setup on the Invoice class file. That is something you need to fix and code. Implement the use of the Comparable interface and add the compareTo() method to the Invoice class. The compareTo() method will take a little work here. We are going to compare via the date of the invoice. The dates of the Invoice class are by default saved in a MM-DD-YYYY format. So they have a dash '-' between each part of the date. So you will need to split the date of the current invoice AND split the date of the object sent to the method. We have three things to compare against here. First we need to check the year. If the years are the same then you should go another step forward and compare the months. If the months are the same then you will lastly have to compare the day. Use whatever…
Stuck and need some assistance
Consider the Person class in Problem 1. Implement the interface PersonPriorityQueueInterface provided in the assignment. In your implementation, you must use an instance of AList (which you used in Problem 1) to store the list of persons.   We consider that a person whose age is higher than a second person also has a higher priority. Thus, the method peek(), for example, should return the person who is the oldest in the list.   Your implementation should be O(n) for add, and O(1) for the remaining methods.   Consider the Person class in Problem 1. Implement the interface PersonPriorityQueueInterface provided in the assignment. In your implementation, you must use an instance of AList (which you used in Problem 1) to store the list of persons.   We consider that a person whose age is higher than a second person also has a higher priority. Thus, the method peek(), for example, should return the person who is the oldest in the list.   Your implementation should be O(n) for add, and O(1)…
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education