Given an ArrayList named receipts, which answer puts the following values into receipts: 12.43, 320.23, 221.98? receipts.insert( {12.43, 320.23, 221.98} ); receipts.insert( 12.43 ); receipts.insert( 320.23 ); receipts.insert( 221.98 ); receipts.add( {12.43, 320.23, 221.98} ); receipts.add( 12.43 ); receipts.add( 320.23 ); receipts.add( 221.98 ); First, if receipts does not have the capacity, then it's contents need to be copied into a new ArrayList that is at least 3 elements longer and the new ArrayList assigned to receipts. Then, each of the values can be copied into receipts.
Q: **/ enable all the selectors that are still available in the scoresheet */ public void…
A: Here, we are going to build the methods to enable and disable the selectors for scores. Enable…
Q: Implement changeArrayLength(int m) – void method; public class Course { public String code;…
A: Answer: I have done code in java and also I have insert the code
Q: Need help with the parts that say TODO in images , This may be needed scoresheet code below package…
A: Comments are lines of text in code that start with a specific set of characters like “//” in…
Q: In Java Write a method called swaplntArrayEnds that is passed the address of an array and swaps the…
A: Writing the java program below
Q: What is the purpose of the following method? Assume that both q1 and q2 are not empty and contains…
A: Answer : Answer is 2 . All elements of q1 which are greater than the first element of q2 will be…
Q: 7. Given an integer array of size Score CAPACITY, override the method getNext () and hasMore ().…
A: PROGRAM CODE: ArrayList.java package arrays; import java.util.AbstractList; /*** This defines the…
Q: Implement a class named Parade using an ArrayList, which will manage instances of class Clown. Each…
A: Implement a class named Parade using an ArrayList, which will manage instances of class Clown. Each…
Q: Create a class called MyArrayList and implement the methods below, in addition to a main method to…
A: Note: Since no programming language is mentioned. I am attempting this in python. if you need it in…
Q: Write a method called swapltems to be considered within the SingleLinkedList class that takes two…
A: size() : to find the size of LinkedList get(index) : to get the element/value at particular position…
Q: 3. What is the advantage of using ArrayList over LinkedList? 4 How much time do you need to add an…
A: 3- Advantage of using ArrayList- ArrayList is quick to select a particular element, although it is…
Q: Suppose we have a method with header: public ArrayList meth (ArrayList list, int n) Which of the…
A: Template Method is a behavioral design pattern that allows you to defines a skeleton of an algorithm…
Q: For the TimeSpan class described below, add a compareTo method that takes another TimeSpan object as…
A: Please find the answer below :
Q: The mergesort method we discussed in the class is applied on the array containing following elements…
A: Summary : -Hence, we got the output.
Q: Finish the Java code Use the binary and sequential search algorithm to search list import…
A: The below answer is coded in java language.
Q: Create an addToHead(int) method that inserts a new integer at the beginning of the linked list. In a…
A: Sample Output Screenshot
Q: Consider the IntArrayBag collection class that we discussed in class, Draw the data array after…
A: SUMMARY: - hence we discussed all the points.
Q: A pet shop wants to give a discount to its clients if they buy one or more pets and at least five…
A: import java.util.Scanner; public class Pets { public static void discount(double[] prices,…
Q: Assume that the following is a method in class LinkedListExample and class KWLinkedList as explained…
A: Itertaor iter is initialized with the first element of list1 traverse through the list - if current…
Q: Given two ArrayLists: list1-[10,20,30], and list2=[40,50], what is the content of the list1 after…
A: Answer: Option d) : [10,20,30,40,50] list1.AddAll(list2) : AddAll operation adds all the elements…
Q: Write import statements used in library.java
A: Write import statements used in library.java
Q: public class QueueEx public static void method1(ArrayQueue q1, ArrayQueue q2) { Iterator iter1 =…
A: Required: java
Q: Need help writing the following method: getWaitlistedStudents() – returns an array of Students in…
A: From the sample code given, it can be seen that waitlist is a linked list of type students. To…
Q: reate a class called RemoveDuplicates that takes a LinkedList of colors (represented using Strings)…
A: Use a variable called duplicateCount and set it when removeDuplicates is called
Q: Consider the binary search method presented in class and shown below. Suppose the method is called…
A: (B) The method will work correctly, even if there are duplicate values, just as long as it is…
Q: (Implement MyLinkedList) The implementation of the methods contains (E e), get(int index), indexOf(E…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: Write a method called swapltems to be considered within the SingleLinkedList class that takes two…
A: Java code to perform the given question is detailed in below with comments and output screenshot.
Q: Write a program in Java that performs the following tasks: Create an ArrayList, HashMap and HashSet…
A: Write the java code using the below steps: Declare an object of an ArrayList. Use the add method to…
Q: Assume you have a method (shown below) inside the KWArrayList class, what does this method do?…
A:
Q: Write a remove method that removes all items between a Start Index and an End Index (Inclusive) in…
A: The solution to the given problem is below.
Q: Write a method called swapltems to be considered within the SingleLinkedList class that takes two…
A: NOTE: Since you have not provided the code for singleLinkedList class so i will assume the code…
Q: ou need to store a list of messages so that the most recently-added message is always first. Should…
A: It is defined as a part of collection framework and is present in java.util package. It provides us…
Q: 1. Suppose you have the following list of integer values to be inserted to your ArrayList: [-1, 2,…
A: Given: Do ArrayList functions.
Q: Question: Consider classes given below. You have write deleteSecondNode( ) method in class…
A: to delete second node from link list we can specify the number or position of node and then delete…
Q: What is printed as a result of executing the following code segment? List list1 = new ArrayList();…
A: In Array list: Add( int X). will add the element Xto last of the list Add(int X, int Y). will add…
Q: We know that the first file name is stored at index zero in the ArrayList, and the list stores the…
A: Yes we can write the body of method listAllfiles along with the following lines given below. Given…
Q: Which of the following are correct ways of declaring a new ArrayList and inserting a value into it?…
A: 1.ArrayList<String> names=new ArrayList<String>(); names.add("Ana"); Explanation we are…
Q: Write a method called SwapMaxMin to be included in the class SingleLinkedList that accepts a…
A: Required: Write a method called SwapMaxMin to be included in the class SingleLinkedList that…
Q: Given the following Java functions, transcribe it into a Python 3 program. /** * Rehashes the…
A: Python3 Source Code: def resize(self, newCapacity): oldTable = table oldCapacity =…
Q: Which of the following statements about ArrayLists is false? O A running program can determine the…
A: Here in this question we have given four option based array list size and we have asked that which…
Q: I am trying to read a CSV file and then store it into an ArrayList. For each row, I'm trying to…
A: As we know that all the classes in java inherit the Object class, and also there are some methods of…
Q: Need help writing the method: getWaitlistedIDs() – returns an array of type int[], namely the ids of…
A: Note: In this question we are asked to modified getWaitlistedIDs method only in java There is a…
Q: Assume you have a folders of (images and videos) in your computer which contain some random mix…
A: Actually, program is a executable software that runs on a computer.
Q: Can you add the comments in this code and tell whats happening in code please import java.util.*;…
A: Program: import java.util.*;//import package for using HashMap class Main//defining Main class {…
Q: Write a program that uses an ArrayList of parameter type Contact to store a database of contacts.…
A: import java.util.ArrayList; import java.util.Scanner; public class Contact { String firstName;…
Q: Write an application in java language using a hash table that finds all the pairs of two integers…
A: Given array is {4,9,6,13,5,3,2,8} Two integers add resultant will be 12.
Q: In this assignment, you will compare the performance of ArrayList and LinkedList. More specifically,…
A: Here is the Code
Q: Define a class StatePair with two generic types (Type1 and Type2), a constructor, mutators,…
A: I have mentioned code in step 2, please find in below
Q: Assume that the following method is in a class called DLL (not same as KWLinkedList). What does this…
A: The listIterator() function class java.util.ArrayList is utilized to return a list iterator over the…
Q: Write a method called swapItems to be considered within the SingleLinkedList class that takes two…
A: NOTE: Here you have not provided the singlelinkedlist class hence i am creating it on my own and…
Q: What is the purpose of the following method? Assume that both q1 and q2 are not empty and contains…
A: ArrayQueue's methods: poll()- pops / deletes the head of the queue and returns it. offer()- Adds an…
Q: This is needed in Java Given an existing ArrayList named friendList, find the first index of a…
A: Java program to solve the given problem is below.
Q: implement changeArrayLength(int m) – void method; public class Course { public String code;…
A: From what us understandable in the question, find the implementation below.
Q: Write a Console Java program that inserts 25 random integers in the range of 0 to 100 into a Linked…
A: As you have not provide the sample output, so we have given the output in Step 4 in the most…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- This program is going to maintain a list of customers’ names and bank account balances. Create a class called CustomerList with a main method that instantiates an ArrayList of String objects called customerName. Invoke the add method to add the following names into the ArrayList: Cathy Ben Jorge Wanda Freddie 2. Print each name in the ArrayList using a for loop. 3. Create another ArrayList object called customerBalance, to save users’ balance. What is the type of this ArrayList? double or Double? You just need to declare this ArrayList and leave it empty for now. 4. For each customer, print the name and ask the user to enter the initial balance for this customer. Save the initial balance into ArrayList customerBalance. Use a loop to get this done for all 5 customers. For example, the program should print out this for the first customer: Please enter the account balance for Cathy: (waiting for user’s input …) Code skeleton: for(int i=0; i<5;i++) { Print(“Please enter…Given these three ArrayLists: ArrayList collectionA = new ArrayList(); ArrayList collectionB = new ArrayList(15); ArrayList collectionC = new ArrayList(25) ; After adding 390 items to each collection, answer the following two questions: Blank 1: Which ArrayList has the largest capacity for the array data member being used internally for storing the items in the object? Blank 2: What is the capacity for the object in blank one? Blank # 1 A Blank # 2 Acode: public class PasswordGeneratorAndStorage {/*** Adds an application to the applications ArrayList. If index is -1, add application* to the end of applications. Else is index is within the size of applications, add* application at that index in applications. Otherwise, return. However, if applications * or application is null, return.* * @param applications* @param application* @param index*/public static void addApplication(ArrayList<String> applications, String application, int index) {// TODO: FILL IN BODY}/*** Generates a random password of length passwordLength and adds it to the end of* passwords if index is -1, or adds it to the index of passwords if index is within the* size of passwords (similar to how the addApplication adds an application). To generate* the random password, use rand to generate a random int within the size of characters. You* can then use this int to grab the char at that index in characters and concatenate that* to your String password variable.…
- Define a class called Book. This class should store attributes such as the title, ISBN number, author, edition, publisher, and year of publication. Provide get/set methods in this class to access these attributes. Define a class called Bookshelf, which contains the main method. This class should create a few book objects with distinct names and store them in an ArrayList. This class should then list the names of all books in the ArrayList. Enhance the program by providing a sort function, which will sort the books in ascending order of their year of publication. Create a few more Bookobjects with the same names but with different edition numbers, ISBNs, and years of publication. Add these new Book objects to the ArrayList, and display the book list sorted by book name; for duplicate books of the same name, sort the list by year of publication. (Hint: You will need to define a comparator class that takes two Book objects as parameters of the compareTo This method should do a two-step…In this programming challenge, you will create a simple trivia game for two players. The program will work like this: • Read the contents of the trivia.txt file into an ArrayList . • Starting with player 1, each player gets a turn at answering one trivia question. (For instance, if there are 10 questions, 5 for each player.) When a question is displayed, four possible answers are also displayed. Only one of the answers is correct, and if the player selects the correct answer, he or she earns a point. • After answers have been selected for all of the questions, the program displays the number of points earned by each player and declares the player with the highest number of points the winner, same as the sample execution. You are to design a Question class to hold the data for a trivia question. The Question class should have String fields for the following data: • A trivia question • Possible answer 1 • Possible answer 2 • Possible answer 3 • Possible answer 4 • The number of the…Which expression should complete the code for the compareTo method of the following Employee class so that objects of the Employee class in an ArrayList are arranged based on alphabetical ordering of the values of the name attributes if the sort method of the Collections class is used to sort the ArrayList. a. this.name.compareTo(another.getName())b. toString().compareTo(another.toString())c. this.compareTo(another)d. 1e. 0
- Which of the following statements about ArrayLists is false? A running program can determine the size of an ArrayList. O You can get an item from a specified index in an ArrayList. O You can add a new item to the end of an ArrayList. O Once an ArrayList is created, its size cannot be changed.Doctor -signature:String -doctorID:int - medicine:Arraylist +Doctor(signature:String,doctorID:int) +PrescribeMedicine():void + salary () +checkRecords():void Medicine Pharmacist -medName:String -startTime:int -dosage :int -endTime:int -date_prescribed:int - medicine:Arraylist +Medicine(medName:String,-dosage :int,date_prescribed:int) +Pharmacist (startTime:int,endTime:int) +checkForConflict():double +confirm_prescription():String +getStartTime():int +getEndTime():int +setStartTime(time:int):void +setEndTime(time1:int).void19. A two-dimensional array is frequently called a matrix and such a matrix is usually displayed in a row X col format. Write a method, which displays a 3 X 4 matrix to the monitor, in a format like: sample data: 10 11 12 13 14 15 16 17 18 19 20 21 Complete method displayMatrix below. // precondition: // postcondition: 11 mat is a non-empty 2D array of int values. displayMatrix displays the elements of 2D array mat in Row X Col format. public static void displayMatrix(int[][] mat)
- Q8. Write a declaration of a private field named department that can hold an ArrayList. The elements of the ArrayList are of type Student. Write an assignment to the department variable to create an appropriate ArrayList object. Q9. (A) If a collection stores 20 objects, what value would be returned from a call to its size method? (B) Write a method call using get to return the fifth object stored in a collection called department. Q10. Write a method call to add the object held in the variable student1 to a collection department files.Create a class called CustomerListerwith a mainmethod that instantiates an array of Stringobjects called customerName. The array should have room for five Stringobjects. Use an initializer list to put the following names into the array:Cathy Ben Jorge Wanda FreddieUse newto create a second doublearray called customerBalancein the mainmethod. Allow room for five customer balances, each stored as a double.In the loop that prints each customer name, add some code to prompt the user to enter a balance for that customer. Read the keyboard input with a Scannerobject. Use the following balances for the input:100.00234.562.4932.32400.00After all the balances have been entered, print out each customer and his/her balance.Which of the following prints the number of elements of the array list? Select one: a. System.out.println(myArrayList.elements()); b. System.out.println(myArrayList.size()); c. System.out.println(myArrayList.size); d. System.out.println(myArrayList.elements);