Data Structures and Algorithms in Java
Data Structures and Algorithms in Java
6th Edition
ISBN: 9781119278023
Author: Michael T. Goodrich; Roberto Tamassia; Michael H. Goldwasser
Publisher: Wiley Global Education US
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
1. What is the difference between a relative cell reference and an absolute cell reference and give an example of when you would use each.
What is the goal of using a chart in excel, and how is a chart useful and what is the goal of using sparklines in excel, and how are sparklines useful?
Prove for each pair of expression f(n) and g(n) whether f(n) is big O, little o Ω,ω or Θ of g(n). Use limits to find these. For each case it is possible that more than one of these conditions is satisfied:1. f(n) =log(n2^n), g(n) = log(sqrt(n)2^(n^2))2. f(n) =nsqrt(n) +log(n^n), g(n) =n + sqrt(n)logn

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
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr