Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
4th Edition
ISBN: 9780134787961
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 7.13, Problem 7.25CP
Write a statement that creates an ArrayList object and assigns its address to a variable named lizards. The ArrayList should be able to store String objects only.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Library class:
Fields: books as arraylist to store all the books available in the library
B3
B1
B2
В4
B5
Constructor:
Library()
}
: No parameterized constructor to create the books object
Methods:
1. addBook(Book bookobj): to add a new book to the arraylist; send the book object as a
parameter to this method.
2. searchBook(String name): search a book by a given name in the arraylist. if exits print
bookX found; otherwise print not found!!!
3. RemoveBook(String name): to delete a book object from arraylist by a given name:
Hint: you need to use iterator class and remove method.
Book class:
Fileds: bookld, bookname.
Constructor: two parameterized constructor that accepts name
a parameter
Book(int ID, String name)
.....
Methods:
1. Accessor method to return the name of the book
2. Mutator method to change the id of the book.
Use this Main method: in your program:
public static void main(String args[])
{
Library lib=new Library();
lib.addBook(new Book("b1"));
lib.addBook(new Book("b2"));…
17. Phone Book ArrayList
Write a class named PhoneBookEntry that has fields for a person's name and phone number.
The class should have a constructor and appropriate accessor and mutator methods. Then
write a program that creates at least five PhoneBookEntry objects and stores them in an
ArrayList. Use a loop to display the contents of each object in the ArrayList.
True or false: All elements in an array of objects must use the same constructor.
Chapter 7 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Ch. 7.1 - Write statements that create the following arrays:...Ch. 7.1 - Whats wrong with the following array declarations?...Ch. 7.1 - Prob. 7.3CPCh. 7.1 - Prob. 7.4CPCh. 7.1 - Prob. 7.5CPCh. 7.1 - Prob. 7.6CPCh. 7.1 - Prob. 7.7CPCh. 7.1 - Prob. 7.8CPCh. 7.2 - Prob. 7.9CPCh. 7.2 - Prob. 7.10CP
Ch. 7.2 - A program has the following declaration: double[]...Ch. 7.2 - Look at the following statements: int[] a = { 1,...Ch. 7.3 - Prob. 7.13CPCh. 7.3 - Write a method named zero, which accepts an int...Ch. 7.6 - Prob. 7.15CPCh. 7.7 - Recall that we discussed a Rectangle class in...Ch. 7.10 - Prob. 7.17CPCh. 7.11 - What value in an array does the selection sort...Ch. 7.11 - How many times will the selection sort swap the...Ch. 7.11 - Prob. 7.20CPCh. 7.11 - Prob. 7.21CPCh. 7.11 - If a sequential search is performed on an array,...Ch. 7.13 - What import statement must you include in your...Ch. 7.13 - Write a statement that creates an ArrayList object...Ch. 7.13 - Write a statement that creates an ArrayList object...Ch. 7.13 - Prob. 7.26CPCh. 7.13 - Prob. 7.27CPCh. 7.13 - Prob. 7.28CPCh. 7.13 - Prob. 7.29CPCh. 7.13 - Prob. 7.30CPCh. 7.13 - Prob. 7.31CPCh. 7 - Prob. 1MCCh. 7 - Prob. 2MCCh. 7 - Prob. 3MCCh. 7 - Prob. 4MCCh. 7 - Array bounds checking happens. a. when the program...Ch. 7 - Prob. 6MCCh. 7 - Prob. 7MCCh. 7 - Prob. 8MCCh. 7 - Prob. 9MCCh. 7 - Prob. 10MCCh. 7 - Prob. 11MCCh. 7 - To delete an item from an ArrayList object, you...Ch. 7 - Prob. 13MCCh. 7 - Prob. 14TFCh. 7 - Prob. 15TFCh. 7 - Prob. 16TFCh. 7 - Prob. 17TFCh. 7 - Prob. 18TFCh. 7 - True or False: The Java compiler does not display...Ch. 7 - Prob. 20TFCh. 7 - True or False: The first size declarator in the...Ch. 7 - Prob. 22TFCh. 7 - Prob. 23TFCh. 7 - int[] collection = new int[-20];Ch. 7 - Prob. 2FTECh. 7 - Prob. 3FTECh. 7 - Prob. 4FTECh. 7 - Prob. 5FTECh. 7 - Prob. 1AWCh. 7 - Prob. 2AWCh. 7 - Prob. 3AWCh. 7 - In a program you need to store the populations of...Ch. 7 - In a program you need to store the identification...Ch. 7 - Prob. 6AWCh. 7 - Prob. 7AWCh. 7 - Prob. 8AWCh. 7 - Prob. 9AWCh. 7 - Prob. 10AWCh. 7 - Prob. 11AWCh. 7 - Prob. 1SACh. 7 - Prob. 2SACh. 7 - Prob. 3SACh. 7 - Prob. 4SACh. 7 - Prob. 5SACh. 7 - Prob. 6SACh. 7 - Prob. 7SACh. 7 - Prob. 8SACh. 7 - Prob. 9SACh. 7 - Rainfall Class Write a RainFall class that stores...Ch. 7 - Payroll Class Write a Payroll class that uses the...Ch. 7 - Charge Account Validation Create a class with a...Ch. 7 - Charge Account Modification Modify the charge...Ch. 7 - Prob. 5PCCh. 7 - Drivers License Exam The local Drivers License...Ch. 7 - Magic 8 Ball Write a program that simulates a...Ch. 7 - Grade Book A teacher has five students who have...Ch. 7 - Grade Book Modification Modify the grade book...Ch. 7 - Average Steps Taken A Personal Fitness Tracker is...Ch. 7 - Array Operations Write a program with an array...Ch. 7 - 12.1994 Gas Prices In the student sample programs...Ch. 7 - Sorted List of 1994 Gas Prices Note: This...Ch. 7 - Name Search If you have downloaded this books...Ch. 7 - Population Data If you have downloaded this books...Ch. 7 - World Series Champions If you have downloaded this...Ch. 7 - 2D Array Operations Write a program that creates a...Ch. 7 - Prob. 18PCCh. 7 - Trivia Game In this programming challenge, you...Ch. 7 - Prob. 20PC
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
You can use the __________ operator to determine whether a key exists in a dictionary. a. b. in c. ^ d. ?
Starting Out with Python (4th Edition)
At a speed of 90 fpm, feed of 0.030 ipr, and depth at 0.625, calculate the input parameters for a lathe if the ...
Degarmo's Materials And Processes In Manufacturing
This optional Google account security feature sends you a message with a code that you must enter, in addition ...
SURVEY OF OPERATING SYSTEMS
Big data Big data describes datasets with huge volumes that are beyond the ability of typical database manageme...
Management Information Systems: Managing The Digital Firm (16th Edition)
ICA 17-24
The decay of a radioactive isotope can be theoretically modeled with the following equation, where C0...
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
In Exercises 1 through 22, determine the output displayed in the text box or list box by the lines of code. Dim...
Introduction To Programming Using Visual Basic (11th 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
- Design an application that declares an array of 20 AutomobileLoan objects. Prompt the user for data for each object, and then display all the values.arrow_forward10. Lottery Application Write a Lottery class that simulates a lottery. The class should have an array of five integers named lotteryNumbers. The constructor should use the Random class (from the Java API) to generate a random number in the range of 0 through 9 for each element in the array. The class should also have a method that accepts an array of five integers that represent a per- son's lottery picks. The method is to compare the corresponding elements in the two arrays and return the number of digits that match. For example, the following shows the lotteryNumbers array and the user's array with sample numbers stored in each. There are two matching digits (elements 2 and 4). lotteryNumbers array: User's array: 7 4 4 2 1 3 7 3 In addition, the class should have a method that returns a copy of the lotteryNumbers array. Demonstrate the class in a program that asks the user to enter five numbers. The program should display the number of digits that match the randomly generated…arrow_forwardJava Program Fleet class- reading from a file called deltafleet.txt-Using file and Scanner Will be creating a file called newfleet.txt Instance Variables:o An array that stores Aircraft that represents Delta Airlines entire fleeto A variable that represents the count for the number of aircraft in the fleet• Methods:o Constructor- One constructor that instantiates the array and sets the count to zeroo readFile()- This method accepts a string that represents the name of the file to beread. It will then read the file. Once the data is read, it should create an aircraft andthen pass the vehicle to the addAircraft method. It should not allow any duplicationof records. Be sure to handle all exceptions.o writeFile()- This method accepts a string that represents the name of the file to bewritten to and then writes the contents of the array to a file. This method shouldcall a sort method to sort the array before writing to it.o sortArray()- This method returns a sorted array. The array is…arrow_forward
- Given the following pseudocode, convert it into the corresponding flowchart. myList(array) { for outerCount := 0 to size-2 do minIndex := outerCount; for innerCount:= outerCount+1 to size – 1 do if array[innerCount] < array[minIndex] then minIndex:= innerCount endloop swap array[outerCount] with array[minIndex]. endloop End//end function myListarrow_forwardinterface IResit { int row = 5; int col = 3; int upperBound = 10; public int[][] initTable(); // initialize 5x3 table with random (upper bound is:10) integer // numbers. “table” is class variable public int[] convertTwoToOne(int[][] a); // convert a two dimensional array into one dimensional // array /* * for example: * a= 1 3 5 * 6 9 -6 * 2 7 4 * * Your method should return: * 4 7 2 -6 9 6 5 3 1 * */ public double averageOfOddElements(int[] a); public double averageOfEvenElements(int[][] a); }// end of the interface /* Write a class that implements the given interface above. 1. Your class should have two constructors: 1. Default constructor: In this case, row, column and upper bound are same as the data that defined in the interface. 2. Overloaded constructor: in this case it should get three parameters, row, column, upper bound respectively. 2. Your constructor parameters are…arrow_forwardAn Iterator is an object that allows your code to produce the elements in a vector or other container one after the other, exactly once. O True Falsearrow_forward
- Calendaritem -month int -day:int Calendaritem(int, int) move(int, int):void +tostring()intring Meeting Birthday -time: String -nameistring +birth year int -participants: ArrayList +Meeting(int, int, String) +addParticipant(String) :void +move(int, int, String):void +Birthday (String, int, int) +toString(): String Based on the UML diagrams shown above, write complete Java class for Birthday, as follows: C) Birthday 1. Define the class and its attributes. Note that Birthday is a subclass of Calendaritem 2. Implement the constructor, which takes 3 parameters for the name, day, and month, and set these values correctly 3. Implement the toString() method to return a string in the following format: name's birthday is on day/month For the toolbar, press ALT F10 (PC) or ALT+FN+F10 (Mac)arrow_forwardRecipe Program - Java ONLYI am looking to create a program that is a recipe holder. It needs to include at a minimum: At least 1 loop An Array or ArrayList At least 3 Java classes Use of methods The program would allow the user to (as part of a menu selection): Add a recipe Include ingredient list Instructions List all recipes that are in the program (array) Display a single recipe Search Recipes (option to view recipe selected) For example, searching for peanut butter cookie would bring up the recipe or multiple if the same name. The user could then select one of them to view the recipe. Search Recipes with a single ingredient (option to view recipe selected) For example: search for coconut and it would bring up coconut cream pie and German chocolate cake. The user could then select one of them to view the recipe. Close application Also need the program in a UML diagram.arrow_forwardWhat happens when a variable no longer refers to an object, such as an array?arrow_forward
- 1. An array is a container that holds a group of values of a 2. Each item in an array is called an 3. Each element is accessed by a numerical 4. The index to the first element of an array is 0 and the index to the last element of the array is the length of the 5. Given the following array declaration, determine which of the three statements below it are true. int [] autoMobile = new int [13]; i. autoMobile[0] is the reference to the first element in the array. ii. autoMobile[13] is the reference to the last element in the array. ii. There are 13 integers in the autoMobile array. 6. In java new is a which is used to allocate memory 7. Declare a one-dimensional array named score of type int that can hold9 values. 8. Declare and initialize a one-dimensional byte array named values of size 10 so that all entries contain 1. 9. Declare and initialize a one-dimensional array to store name of any 3 students. 10. Declare a two-dimensional array named mark of type double that can hold 5x3…arrow_forwardWrite Xojo Code to create the array Planets and Assign values. Planets: Venus Earth Mars Jupiter Saturn Uranus Neptunearrow_forward4. How do you add items to an ArrayList object?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
9.1: What is an Array? - Processing Tutorial; Author: The Coding Train;https://www.youtube.com/watch?v=NptnmWvkbTw;License: Standard Youtube License