Java: An Introduction to Problem Solving and Programming (7th Edition)
7th Edition
ISBN: 9780133766264
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 (7th 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 - 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
- Exercising a challenge Read the footnote on the asList method for Arrays. Locate and read the sections on class variables and class methods later in this chapter. Explain how this works in your own words.arrow_forwardCompare 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_forward
- Using the new operator, allocate a two dimensional integer array. The number of rows and columns are going to be provided by the user as input. However, in this task, all of the rows are not the same size (the array is uneven).The user will specify how many elements the individual rows will have. Assign values to the array elements by taking user inputs and then print the values. Finally de-allocate the array using the delete operator.arrow_forwardAdd methods to the STUDENT class that compare two STUDENT objects. One method should test for equality. The other methods should support the other possible comparisons. In each case, the method returns the result of the comparison of the two students' names. Place several STUDENT objects into a list and shuffle it. Then run the SORT method with this list and display all of the students' information.arrow_forwardPlease help me with this using JavaScriptarrow_forward
- /** * The constructor has been partially implemented for you. cards is the * ArrayList where you'll be adding all the cards you're given. In addition, * there are two arrays. You don't necessarily need to use them, but using them * will be extremely helpful. * * The rankCounts array is of the same length as the number of Ranks. At * position i of the array, keep a count of the number of cards whose * rank.ordinal() equals i. Repeat the same with Suits for suitCounts. For * example, if your Cards are (Clubs 4, Clubs 10, Spades 2), your suitCounts * array would be {2, 0, 0, 1}. * * @param cards * the list of cards to be added */ public PokerAnalysis(List<Card> cards) { this.cards = new ArrayList<Card>(); this.rankCounts = new int[Rank.values().length]; this.suitCounts = new int[Suit.values().length]; throw new UnsupportedOperationException(); }arrow_forwardQ1. Let's assume that you have a variable "words" of type ArrayList, already filled with some values. Write the loop to go over each element in the list and count the total number of characters used for all words. In other words, call the method length() on each string and do the sum of all those numbers returned. Do not use a For-Each loop.arrow_forwardPlease answer the questions in image. Please answer question 1.1 and Question 1.2 (A, B,and C ) Separately . Please explain also. The 1 and 2 written in black just shows that this is the 1st picture and this is the 2nd picturearrow_forward
- Note that you can only use recursion to solve Q1 and you cannot use any loop. You are free to add helper methods, but you are not allowed to change the method header.Question 1: Crazy seriesIn this session, you need to implement the crazy series method. In the crazy series, you will be given a starting number. Then, you need to times 2 for each number until the number is greater than 100. After the number is greater than 100, you need to divide 3 until we reach the number is less than 5. Note that the input number must be greater than 0, and you are not allowed to use loop here.For example,crazySeries(10) should return ArrayList [10.0, 20.0, 40.0, 80.0, 160.0, 53.333333333333336, 17.77777777777778, 5.9259259259259265, 1.9753086419753088]crazySeries(5) should return ArrayList [5.0, 10.0, 20.0, 40.0, 80.0, 160.0, 53.333333333333336, 17.77777777777778, 5.9259259259259265, 1.9753086419753088]crazySeries(1) should return ArrayList [1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0,…arrow_forwardIn this exercise, we will be looking at our example code for Selection Sort. However, while we are sorting we will also count the number of swaps taking place, then print them out once the array has been sorted. Add a print statement at the end of the selectionSort method that prints out the number of swaps that took place during the sort. You should not modify the main() method. Hint: Where are items compared? Try writing out the steps in the algorithm on paper to help.arrow_forwardA readinglist is a doubly linked list in which each element of the list is a book. So, you must make sure that Books are linked with the previous prev and next element. A readinglist is unsorted by default or sorted (according to title) in different context. Please pay attention to the task description below. Refer to the relevance classes for more detail information. Implement the add_book_sorted method of the ReadingList class. Assume the readinglist is sorted by title, the add_book_sorted method takes an argument new_book (a book object), it adds the new_book to the readinglist such that the readinglist remain sorted by title. For example, if the readinglist contain the following 3 books: Title: Artificial Intelligence Applications Author: Cassie Ng Published Year: 2000 Title: Python 3 Author: Jack Chan Published Year: 2016 Title: Zoo Author: Cassie Chun Published Year: 2000 If we add another book (titled "Chinese History"; author "Qin Yuan"; and published year 1989) to the…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