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
Consider the Account class in the below. In the class, the withdraw() method audits whenmoney is withdrawn. In order to test the withdraw() method, a stub should be provided for theaudit object. Implement the stub structure shown in the class diagram and test withdraw()method using the StubAudit class.
Consider a class PersonAddress that represents an entry in an addressbook. Its attributes are• The first name of the person• The last name of the person• The e-mail address of the person• The telephone number of the personIt will have methods to• Access each attribute• Change the e-mail address• Change the telephone number• Test whether two instances are equal based solely on namea. Write a method heading for each method.b. Write preconditions and postconditions for each method.c. Write some Java statements that test the class.d. Implement the class.
please implement the code for password validation by considering all scenarios and run it, if it runs with the correct answer I will upvote
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