Data Structures and Algorithms in Java
Data Structures and Algorithms in Java
6th Edition
ISBN: 9781118771334
Author: Michael T. Goodrich
Publisher: WILEY
Question
Book Icon
Chapter 1, Problem 12R
Program Plan Intro

Processing a negative payment amount

Program plan:

  • Import the required packages.
  • Create a class CreditCard to modify the class by ignoring any request to process the negative payment amount.
  • Declare required variables.
  • The parameterized constructor CreditCard() takes the input parameters of “cust”, “bk”, “acnt”, “lim”, and “initialBal” to initialize the values.
  • The parameterized constructor CreditCard() takes the input parameters of “cust”, “bk”, “acnt”, and “lim” to initializes the values.
  • The accessor method getCustomer() is to get the customer name.
  • The accessor method getBank() is to get the bank name.
  • The accessor method getAccount() is to get the account number.
  • The accessor method getLimit() is to get the credit limit.
  • The accessor method getBalance() is to get the credit balance.
  • The method charge() is to update the balance.
  • The method makePayment() is to make a payment when amount is not a negative payment.
  • The utility method printSummary() is to display the credit card’s information.
  • In main() function.
    • Create an instance for CreditCard class.
    • Initialize the value for credit card details by invoking the parameterized constructors using wallet object.
    • Call the charge() method is to update the balance using wallet object for 3 arrays.
    • Loop executes until the wallet[] object.
      • Call the printsummary() method is to display the credit card details.
      • Loop executes until the getBalance() method value is greater than 200. If yes,
        • Call to makePayment() method to make a payment, then display the new balance.

Blurred answer
Students have asked these similar questions
Please implement in Java implement a keyed bag in which the items to be stored are strings (perhaps people’s names) and the keys are numbers (perhaps Social Security or other identification numbers). So, the in- sertion method has this specification: public void insert(String entry, int key);// Precondition: size( ) < CAPACITY, and the // bag does not yet contain any item// with the given key.// Postcondition: A new copy of entry has// been added to the bag, with the given key. When the programmer wants to remove or retrieve an item from a keyed bag, the key of the item must be specified rather than the item itself. The keyed bag should also have a boolean method that can be used to determine whether the bag has an item with a specified key. In a keyed bag, the pro- grammer using the class specifies a particular key when an item is inserted. Here’s an implementation idea: A keyed bag can have two private arrays, one that holds the string data and one that holds the corresponding…
class B extends A {} is the correct way to implement an interface in Java. True or False?
Write a set of Java classes that can simulate an Internet application in which one party, Alice, is periodically creating a set of packets that she wants to send to Bob. An Internet process is continually checking if Alice has any packets to send, and if so, it delivers them to Bob’s computer; Bob is periodically checking if his computer has a packet from Alice, and if so, he reads and deletes it.

Chapter 1 Solutions

Data Structures and Algorithms in Java

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