Data Structures and Algorithms in Java
6th Edition
ISBN: 9781118771334
Author: Michael T. Goodrich
Publisher: WILEY
expand_more
expand_more
format_list_bulleted
Question
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.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
The question is p8. 2
53. Write a class with two instance variables, representing an old password and
a new password. Write a recursive method that returns the number of places
where the two passwords have different characters. The passwords can have
different lengths. Write another, nonrecursive method returning whether the
two passwords are sufficiently different. The method takes an int parameter
indicating the minimum number of differences that qualify the passwords as
being sufficiently different. Your program should include a client class to test
your class.
write code in python language
Chapter 1 Solutions
Data Structures and Algorithms in Java
Ch. 1 - Prob. 1RCh. 1 - Suppose that we create an array A of GameEntry...Ch. 1 - Write a short Java method, isMultiple, that takes...Ch. 1 - Write a short Java method, isEven, that takes an...Ch. 1 - Write a short Java method that takes an integer n...Ch. 1 - Write a short Java method that takes an integer n...Ch. 1 - Write a short Java method that takes an integer n...Ch. 1 - Write a short Java method that counts the number...Ch. 1 - Prob. 9RCh. 1 - Prob. 10R
Ch. 1 - Modify the CreditCard class from Code Fragment 1.5...Ch. 1 - Prob. 12RCh. 1 - Modify the declaration of the first for loop in...Ch. 1 - Prob. 14CCh. 1 - Write a pseudocode description of a method for...Ch. 1 - Write a short program that takes as input three...Ch. 1 - Write a short Java method that takes an array of...Ch. 1 - Prob. 18CCh. 1 - Write a Java program that can take a positive...Ch. 1 - Write a Java method that takes an array of float...Ch. 1 - Write a Java method that takes an array containing...Ch. 1 - Prob. 22CCh. 1 - Write a short Java program that takes two arrays a...Ch. 1 - Modify the CreditCard class from Code Fragment 1.5...Ch. 1 - Modify the CreditCard class to add a toString()...Ch. 1 - Write a short Java program that takes all the...Ch. 1 - Write a Java program that can simulate a simple...Ch. 1 - A common punishment for school children is to...Ch. 1 - The birthday paradox says that the probability...Ch. 1 - (For those who know Java graphical user interface...
Knowledge Booster
Similar questions
- function in Python called PassFail(), that returns the number of points required on the last exam in order to pass this class based on the first four exam points and the 55% exam standard mentioned in the syllabus. Note: there are a total of five exams. The first four exams are worth 100 points each. The fifth and last exam is worth 200 points.arrow_forwardP8.2 Implement a class Quiz that implements the Measurable interface. A quiz has a score and a letter grade (such as B+). Use the Data class of Exercise P8.1 to process an array of quizzes. Display the average score and the quiz with the highest score (both letter grade and score).arrow_forwardUse Java.arrow_forward
- 1. Implement the above system using inheritance in the best possible way. Keep every object size as small as possible. Implement all methods (setter/getter/constructors and destructors) Note that the region area is 0 while the city is len*width and the country is the sum of their cities. 2. Create array of countries called Arab of 22 countries, Write a function fill that fills the arrav Arab 3. Write a method that finds the city that has the max area in a country 4. Write a method that sorts the cities in a country from the largest to the smallest area 5. Write a function that retums array of countries of the same area of Arab 6. Write a function that compares between two countries. It returns true if countryl area greater than country2 area. 7. Write a function to move a city from one country to another.arrow_forwardWrite code for the InternetThing class to complete: a. A constructor that accepts a manufacturer and a serial number as its parameter. This constructor performs the following actions: i Store the serial number as a string ii Set a unique id number as an integer(hint- use the nextId). iii Set the IP address to the value “192.168.0.”+idnumber iv Set a local representation of a the power used in mW to the integer 1. v Set the password to “admin”. vi Prints the value “Created ”+ the result of the toString() method after assigning all instance data. vii Increment the number of things on record. b. Accessors for all private variables – Ensure the accessors for id, password and powerUse are named getId(), getPassword() and getPowerUse() c. A method setPassword that accepts a string argument and sets the instance password to the argument. All instance variables, except the password, should be private. The password should be protected. In class SmartHome, method addThing, • Create a…arrow_forwardJava with screen shot pleasearrow_forward
- Suppose you are a backend developer for a tech news platform. You have been asked to design a templating system for their news articles. To do this, you will need to run some proof of concepts. Define the TabletComputer class in the main.py file so that the code in Snippet 7.19 runs without error: # Write your TabletComputer class here uPad = TabletComputer(12.9, "1TB", "uPadOS 13.5.1")rootProX = TabletComputer(13.0, "512GB", "Glass 10 Home") print(f"The new uPad has a {uPad.screen_size}" f" inch display. A maximum {uPad.storage} of storage and runs on" f" the latest version of {uPad.os}. Its biggest competitor is" f" the Root Pro X which holds a similar {rootProX.screen_size}" f" inch display, with a maximum storage capacity of {rootProX.storage} and runs {rootProX.os}." ) Define the __init__ function within the TabletComputer class with the necessary parameters to set up the member variables. You will need to set the following member variables: screen_size…arrow_forwardin c++arrow_forwardJava Question.arrow_forward
- write in java Program a class representing a player hand. The hand should be unbounded in size. A hand should have some data structure containing cards. We should be able to add a card to the hand and remove a card from the hand. Cards should always be added to the end of the hand, but can be removed from any point in the hand. We should also be able to shuffle our hand, examine any card in our hand, count the cards in our hand, sort our hand by value (both from being completely unsorted and upon adding a card to or removing a card from a sorted hand), and search a sorted hand for cards of a specific value. You may implement any helper methods you needarrow_forwardWrite a C++ program that will display multiple-choice trivia questions, accept the user's answers, and provide a full key and a score at the end. Design and implement a class called Question. The Question class contains the following information: a stem (the text of the trivia question) an array of 4 multiple choice answers (the text of each possible answer) the letter of the correct answer (A, B, C, or D), called the key. This class will be used to represent trivia questions in a trivia game. The following operations should be available for Question objects (use the provided names). Construct a Question with no values (use empty strings for stem and answers and 'X' for the key). Construct a Question given its 3 components (). setStem: Set the stem question. getStem: Return the stem question. setAnswers: Set the 4 answers given an array. The answers will NOT include the letter (A, B, C, or D). getAnswer(i): Return the single answer at index i. setKey: Set the key letter. getKey:…arrow_forwardUsing Python Languagearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education