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
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
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
- Write a program in the Java language requires the management of university students, where student data (name, student number, and specialization) are saved, and then he can add and delete study materials for the current semester, and you can also add the grade for each subject (with the addition of the final code for the degree automatically).Note: The class principle is used to solve this assignment.arrow_forwardWrite some code to generate an instance where variable x has both the static and dynamic types T and D, respectively.arrow_forwardWrite a class SortTransactions that consists of a static method main() that reads a sequence of transactions from standard input, sorts them, and prints the result on standard outputarrow_forward
- Implement the following class using javaarrow_forwardWrite a JAVA program that reads an array from input file and invokes twodifferent methods Sort and Max ,that sorts the elements of the array and findsthe Max element and writes out the resulted array in to output file . Usetwo interfaces for methods and throw Exception Handling for Out Of Boundindex for the array.arrow_forwardWrite a class SortTransactions that consists of astatic method main() that reads a sequence of transactions from standard input, sortsthem, and prints the result on standard outputarrow_forward
- Use a Bootstrap class to center the following text: <p class="">Hello World!</p>arrow_forwardWrite a postcondition for the following in Guarded Command Language (G.C.L): 1. Given P[0..100) of int, determine whether the first 10 values in P are a copy of the last 10 values in P.arrow_forwardThe goal of this second exercise is to develop a better understanding of the Linuxinterprocess communication mechanisms. This would require you to write twoprograms P1 and P2. The first program P1 needs to generate an array of 50random strings (of characters) of fixed length each. P1 then sends a group offive consecutive elements of the array of strings to P2 along with the ID’s ofthe strings, where the ID is the index of the array corresponding to the string.The second program P2 needs to accept the received strings, and send backthe highest ID received back to P1 to acknowledge the strings received. Theprogram P2 simply prints the ID’s and the strings on the console. On receivingthe acknowledged packet, P1 sends the next five strings, with the string elementsstarting from the successor of the acknowledged ID. The above mechanism needs to be implemented FIFO and UNIX DOMAIN SOCKETS. Please note that you may NOT make assumptions about the reliability of the interprocess communication…arrow_forward
- write easy java program. Implement a class Quiz that implements the Measurable interface. A quiz has a scoreand a letter grade (such as B+). Use the Data class of Exercise P8.1 to processan array of quizzes. Display the average score and the quiz with the highestscore (both letter grade and score).arrow_forwardWrite a java program that enables the user to enter a string and an index,then cuts the letter in the given index(only cuts the single letter). Then prints the new string without that letterarrow_forwardImplement the Plates class buildMap function so that it populates the HashMap with the state abbreviations as keys and the counts of how many each appear in the file as values. Sometimes, the parking attendant will add special notation to help her remember something about a specific entry. There are just non alphabetic characters that she adds to the state - your program should ignore these characters so that an entry like NY* still counts toward the NY plate count. She is also very inconsistent with how she enters the plates. Sometimes she uses upper case, sometimes lowercase, and sometimes she even uses a mix. Be sure to account for this in your program. Only add information for plates in New England (Maine, New Hampshire, Vermont, Massachusetts, Rhode Island, and Connecticut). Plates.java import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; public class Plates { private Map<String, Integer> plateMap;…arrow_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