Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 12, Problem 4E
Repeat Exercises 6 and 7 in Chapter 7, but use an instance of ArrayList instead of an array. We will no longer need to know the maximum number of sales, so the methods will change to reflect this.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Challenge exercise What are examples of other methods that the Arrays class provides?
Write assignments to the library, cs101, and track variables (which you defined in the previous three exercises) to create the appropriate ArrayList objects. Write them once using diamond notation and once without diamond notation, specifying the full type.
Challenge exercise Read the footnote about the Arrays. asList method. Find and read the sections later in this chapter about class -variables and class methods. Explain in your own words how this works.
Chapter 12 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Ch. 12.1 - Suppose aList is an object of the class...Ch. 12.1 - Prob. 2STQCh. 12.1 - Prob. 3STQCh. 12.1 - Prob. 4STQCh. 12.1 - Can you use the method add to insert an element at...Ch. 12.1 - Prob. 6STQCh. 12.1 - Prob. 7STQCh. 12.1 - If you create a list using the statement...Ch. 12.1 - Prob. 9STQCh. 12.1 - Prob. 11STQ
Ch. 12.1 - Prob. 12STQCh. 12.2 - Prob. 13STQCh. 12.2 - Prob. 14STQCh. 12.2 - Prob. 15STQCh. 12.2 - Prob. 16STQCh. 12.3 - Prob. 17STQCh. 12.3 - Prob. 18STQCh. 12.3 - Prob. 19STQCh. 12.3 - Write a definition of a method isEmpty for the...Ch. 12.3 - Prob. 21STQCh. 12.3 - Prob. 22STQCh. 12.3 - Prob. 23STQCh. 12.3 - Prob. 24STQCh. 12.3 - Redefine the method getDataAtCurrent in...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.4 - Revise the definition of the class ListNode in...Ch. 12.4 - Prob. 30STQCh. 12.5 - What is the purpose of the FXML file?Ch. 12.5 - Prob. 32STQCh. 12 - Repeat Exercise 2 in Chapter 7, but use an...Ch. 12 - Prob. 2ECh. 12 - Prob. 3ECh. 12 - Repeat Exercises 6 and 7 in Chapter 7, but use an...Ch. 12 - Write a static method removeDuplicates...Ch. 12 - Write a static method...Ch. 12 - Write a program that will read sentences from a...Ch. 12 - Repeat Exercise 12 in Chapter 7, but use an...Ch. 12 - Write a program that will read a text file that...Ch. 12 - Revise the class StringLinkedList in Listing 12.5...Ch. 12 - Prob. 12ECh. 12 - Write some code that will use an iterator to...Ch. 12 - Prob. 14ECh. 12 - Write some code that will use an iterator to...Ch. 12 - Prob. 17ECh. 12 - Revise the method selectionSort within the class...Ch. 12 - Repeat the previous practice program, but instead...Ch. 12 - Repeat Practice Program 1, but instead write a...Ch. 12 - Write a program that allows the user to enter an...Ch. 12 - Write a program that uses a HashMap to compute a...Ch. 12 - Write a program that creates Pet objects from data...Ch. 12 - Repeat the previous programming project, but sort...Ch. 12 - Repeat the previous programming project, but read...Ch. 12 - Prob. 9PPCh. 12 - Prob. 10PPCh. 12 - Prob. 11PPCh. 12 - Prob. 12PPCh. 12 - Prob. 13PPCh. 12 - Prob. 14PPCh. 12 - Prob. 15PP
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Will the Java compiler translate a source file that contains syntax errors?
Starting Out with Java: Early Objects (6th Edition)
Consider the following C program void fun (void) { int a, b, c; / defiinition.1 / . . . while (. . .) int b, c,...
Concepts Of Programming Languages
Write a complete Java program that uses to output the following to the screen when run:
Note that you do no...
Absolute Java (6th Edition)
Create an ArrayList<String> in the Code Pad by typing the following two lines:
If you write the last line wi...
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Describe a method that can be used to gather a piece of data such as the users age.
Web Development and Design Foundations with HTML5 (8th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Compare and contrast the array and arrayList. Give at least one example that describe when to use arrayList compared to an array.arrow_forwardImplement one of the sorts described in Chapters 15 and 16. Input is an array with at least 10 items. The items in the array can be of several types (Suggested types are integers-denoting how many customers visited the store in the last three weeks or strings-denoting the names of featured items). The items should be connected to a store in some way. Use some of the given data fields Print a title indicating what the data represents. Print the original data, AND the sorted data.arrow_forwardPlease help me with this using JavaScriptarrow_forward
- Create an ArrayList of strings to store the names of celebrities or athletes. Add five names to the list. Process the list with a for loop and the get() method to display the names, one name per line. Pass the list to a void method. Inside the method, Insert another name at index 2 and remove the name at index 4. Use a foreach loop to display the arraylist again, all names on one line separated by asterisks. After the method call in main, create an iterator for the arraylist and use it to display the list one more time.arrow_forwardCreate 1 method to output the list of numbers. Output the list of numbers input by user. Output the average of all the numbers. Attach Snipping photos of source code and output. Task 2 Update above program. Create a Method that will return the largest element in the array. Attach Snipping photos of source code and output.arrow_forwardImplement a city database using ordered lists. Each database record contains the name of the city (a string of arbitrary length) and the coordinates of the city expressed as integer x and y coordinates. Your database should allow records to be inserted, deleted by name, and searched by name. Another operation that should be supported is to print all records within a given distance of a specified point/coordinate. The order of cities should be alphabetically by city name. Implement the database using: an array- based list implementation. By using JAVA.arrow_forward
- The for construct is a kind of loop that iteratively processes a sequence of items. So long as there are things to process, it will continue to operate. In your opinion, how true is this statement?arrow_forwardExecute the following statements over initially empty ArrayList myList one after another (cascade). Explain what was changed after each statement (what did it do?) myList.add("z"); ArrayList content: Your explanation (where this output came from): myList.add(0, "a"); ArrayList content: Your explanation (where this output came from): myList.add("t"); ArrayList content: Your explanation (where this output came from): myList.add(2,"w"); ArrayList content: Your explanation (where this output came from): myList.set(0,"b"); ArrayList content: Your explanation (where this output came from):arrow_forwardIs there a way to simataniously get both student names' and roll numbers' to be in ascending order at the same time in one block display? What would that look like? Right now I have to call both methods seperatly in order to see both ascending methods in action and it doesn't look good...Also is it possible to separate the sorting logic from the main method and encapsulate it within a separate class or method that takes the ArrayList of students and the two comparators as arguments?... allowing the program to sort students by different criteria without duplicating the sorting logic? The attached image is what my program is displaying right now and I want it to display like: Student [roll number =1, name =Allan, address =620 pioneer st]Student [roll number =2, name =Billy, address =700 ash st]Student [roll number =3, name =Chris, address =801 cheney dr]Student [roll number =4, name =Diana, address =830 washington st]Student [roll number =5, name =Eliza, address =200 main st]Student…arrow_forward
- java Write a program to do the following: Create an ArrayList of Student. Add 7 elements to the ArrayList. Use for each loop to print all the elements of an ArrayList. Remove an element from an ArrayList using the index number. Remove the element from an ArrayList using the content (element name).arrow_forwardPlease use java only and public int method. Show the steps with the pictures also. In this assignment, you will implement a class calledArrayAndArrayList. This class includes some interesting methods for working with Arrays and ArrayLists. For example, the ArrayAndArrayList class has a “findMax” method which finds and returns the max number in a given array. For a defined array: int[] array = {1, 3, 5, 7, 9}, calling findMax(array) will return 9. There are 4 methods that need to be implemented in the A rrayAndArrayList class: ● howMany(int[] array, int element) - Counts the number of occurrences of the given element in the given array. ● findMax(int[] array) - Finds the max number in the given array. ● maxArray(int[] array) - Keeps track of every occurrence of the max number in the given array. ● swapZero(int[] array) - Puts all of the zeros in the given array, at the end of the given array. Each method has been defined for you, but without the code. See the javadoc for each…arrow_forwardImplement solutions for the following methods: • getCourseSize() – returns the number of students registered in the course (not in the waitlist). It should maintain the public size variable that keeps track of the number of students registered. • getRegisteredIDs() – returns an array of int[], namely registered student id’s. The length of the array is the size (number of students) in the course. • getRegisteredStudents() – returns an array of type Student[], namely the registered Students. The length of the array is the current size (number of students) of the course. • getWaitlistedIDs() – returns an array of type int[], namely the ids of students in the waitlist. • getWaitlistedStudents() – returns an array of Students in the waitlist. public class Course { public String code; public int capacity; public SLinkedList<Student>[] studentTable; public int size; public SLinkedList<Student> waitlist; public Course(String code) {…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
Introduction to Big O Notation and Time Complexity (Data Structures & Algorithms #7); Author: CS Dojo;https://www.youtube.com/watch?v=D6xkbGLQesk;License: Standard YouTube License, CC-BY