Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
7th Edition
ISBN: 9780134802213
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 9.3, Problem 9.10CP
Program Plan Intro
String class:
- The “String” class provides a number of methods that examines for a string inside of a string.
- The term “substring” refers to a string that denotes another string’s part.
- The “startsWith” method would determine whether calling string of object begins with a specific substring.
- The method returns “true” if string begins with specified substring, it returns “false” otherwise.
- The “endsWith” method would determine whether calling string would end with a specified substring.
- The method returns “true” if string ends with specified substring, it returns “false” otherwise.
- The “regionMatches” method would determine whether specified regions for two strings match.
- The first argument of this method can be “true” or “false” that indicates whether a case-insensitive comparison could be performed.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
The code given below represents a saveTransaction() method which is used to save data to a database from the Java program. Given the classes in the image as well as an image of the screen which will call the function, modify the given code so that it loops through the items again, this time as it loops through you are to insert the data into the salesdetails table, note that the SalesNumber from the AUTO-INCREMENT field from above is to be inserted here with each record being placed into the salesdetails table. Finally, as you loop through the items the product table must be update because as products are sold the onhand field in the products table must be updated. When multiple tables are to be updated with related data, you should wrap it into a DMBS transaction.
The schema for the database is also depicted.
public class PosDAO { private Connection connection; public PosDAO(Connection connection) { this.connection = connection; } public void…
What is the difference between the remove and discard methods?
What is a HashMap? What is its purpose and how do you use it? Answer these questions in writing, and use the Java library documentation of Map and HashMap for your responses. Note that you will find it hard to understand everything, as the documentation for these classes is not very good. We will discuss the details later in this chapter, but see what you can find out on your own before reading on.
Chapter 9 Solutions
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Ch. 9.2 - Prob. 9.1CPCh. 9.2 - Write an if statement that displays the word digit...Ch. 9.2 - Prob. 9.3CPCh. 9.2 - Write a loop that asks the user, Do you want to...Ch. 9.2 - Prob. 9.5CPCh. 9.2 - Write a loop that counts the number of uppercase...Ch. 9.3 - Prob. 9.7CPCh. 9.3 - Modify the method you wrote for Checkpoint 9.7 so...Ch. 9.3 - Look at the following declaration: String cafeName...Ch. 9.3 - Prob. 9.10CP
Ch. 9.3 - Prob. 9.11CPCh. 9.3 - Prob. 9.12CPCh. 9.3 - Prob. 9.13CPCh. 9.3 - Look at the following code: String str1 = To be,...Ch. 9.3 - Prob. 9.15CPCh. 9.3 - Assume that a program has the following...Ch. 9.4 - Prob. 9.17CPCh. 9.4 - Prob. 9.18CPCh. 9.4 - Prob. 9.19CPCh. 9.4 - Prob. 9.20CPCh. 9.4 - Prob. 9.21CPCh. 9.4 - Prob. 9.22CPCh. 9.4 - Prob. 9.23CPCh. 9.4 - Prob. 9.24CPCh. 9.5 - Prob. 9.25CPCh. 9.5 - Prob. 9.26CPCh. 9.5 - Look at the following string:...Ch. 9.5 - Prob. 9.28CPCh. 9.6 - Write a statement that converts the following...Ch. 9.6 - Prob. 9.30CPCh. 9.6 - Prob. 9.31CPCh. 9 - The isDigit, isLetter, and isLetterOrDigit methods...Ch. 9 - Prob. 2MCCh. 9 - The startsWith, endsWith, and regionMatches...Ch. 9 - The indexOf and lastIndexOf methods are members of...Ch. 9 - Prob. 5MCCh. 9 - Prob. 6MCCh. 9 - Prob. 7MCCh. 9 - Prob. 8MCCh. 9 - Prob. 9MCCh. 9 - Prob. 10MCCh. 9 - To delete a specific character in a StringBuilder...Ch. 9 - Prob. 12MCCh. 9 - This String method breaks a string into tokens. a....Ch. 9 - These static final variables are members of the...Ch. 9 - Prob. 15TFCh. 9 - Prob. 16TFCh. 9 - True or False: If toLowerCase methods argument is...Ch. 9 - True or False: The startsWith and endsWith methods...Ch. 9 - True or False: There are two versions of the...Ch. 9 - Prob. 20TFCh. 9 - Prob. 21TFCh. 9 - Prob. 22TFCh. 9 - Prob. 23TFCh. 9 - int number = 99; String str; // Convert number to...Ch. 9 - Prob. 2FTECh. 9 - Prob. 3FTECh. 9 - Prob. 4FTECh. 9 - The following if statement determines whether...Ch. 9 - Write a loop that counts the number of space...Ch. 9 - Prob. 3AWCh. 9 - Prob. 4AWCh. 9 - Prob. 5AWCh. 9 - Modify the method you wrote for Algorithm...Ch. 9 - Prob. 7AWCh. 9 - Look at the following string:...Ch. 9 - Assume that d is a double variable. Write an if...Ch. 9 - Write code that displays the contents of the int...Ch. 9 - Prob. 1SACh. 9 - Prob. 2SACh. 9 - Prob. 3SACh. 9 - How can you determine the minimum and maximum...Ch. 9 - Prob. 1PCCh. 9 - Prob. 2PCCh. 9 - Prob. 3PCCh. 9 - Prob. 4PCCh. 9 - Prob. 5PCCh. 9 - Prob. 6PCCh. 9 - Check Writer Write a program that displays a...Ch. 9 - Prob. 8PCCh. 9 - Prob. 9PCCh. 9 - Word Counter Write a program that asks the user...Ch. 9 - Sales Analysis The file SalesData.txt, in this...Ch. 9 - Prob. 12PCCh. 9 - Alphabetic Telephone Number Translator Many...Ch. 9 - Word Separator Write a program that accepts as...Ch. 9 - Pig Latin Write a program that reads a sentence as...Ch. 9 - Prob. 16PCCh. 9 - Lottery Statistics To play the PowerBall lottery,...Ch. 9 - Gas Prices In the student sample program files for...
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
- In this java assignment, we will need to use arraylists so we can store data for an employee. If the user wants to enter data for more than one employee, it should print like this: Employee ListId Name ----------------------- 1. First Name 2. Bob Smith If the user only enters one employee, it should print out a paystub for that employee that would look like this (with overtime coming into play as well, paying an extra 50% beyond 40 hours): ------------------------------- Id - 1 Name - First M. Last Address - 1234 Main St, City, St, Zip Phone - 1234567890 Email - sample@gmail.com Hours worked - 45 Hourly Rate - $10 Regular Pay, 40 hours at $10/hr - $400 Overtime Pay, 5 hours at $15/hr - $75 Gross Total - $475 ------------------------------ Federal tax (20%) - $95 State Tax (5%) - $23.75 Fica Tax (3%) - $14.25 ------------------------------ Net Check - $342 The program should have one class per .java file all calling to a main.java file using getters and setters. Here are the…arrow_forwardWhich 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. 0arrow_forwardThere's a "users" table that has more than 1M rows of "users" information. The image below are the first 3 rows.Implement a SQL query that retrieves the "email" and "friend_count" of the "user_id" with the most friends.arrow_forward
- Please read the instructions carefully and keep in mind of the bolded phrases. You are NOT ALLOWED to use HashSet Create a project in NetBeans and name the project Hw06. The class will contain the following static methods: reverseS – A method that displays a string reversely on the console using the following signature: publicstaticvoidreverseS(Strings) printSub1 – print all substrings of a string (duplicated substrings are allowed, but loops are not allowed). The method signature: public static void printSub1(String s) printSub2 – print all substrings of a string (duplicated substrings are not allowed, but loops are allowed). The method signature: public static void printSub2(String s) Note: All methods should be RECURSIVE. Any predefined classes that are based on Set are not allowed. In the main method, read a string from the user and output the reversed string and substrings to the screen: Sample Run: Please input a string: abcdThe reversed string: dcbaThe substrings…arrow_forwardFor any element in keysList with a value greater than 100, print the corresponding value in itemsList, followed by a space. Ex: If keysList = {42, 105, 101, 100} and itemsList = {10, 20, 30, 40}, print:20 30 Since keysList.at(1) and keysList.at(2) have values greater than 100, the value of itemsList.at(1) and itemsList.at(2) are printed. #include <iostream>#include <vector>using namespace std; int main() { const int SIZE_LIST = 4; vector<int> keysList(SIZE_LIST); vector<int> itemsList(SIZE_LIST); unsigned int i; for (i = 0; i < keysList.size(); ++i) { cin >> keysList.at(i); } for (i = 0; i < itemsList.size(); ++i) { cin >> itemsList.at(i); } /* Your solution goes here */ cout << endl; return 0;}arrow_forwardFor any element in keysList with a value greater than 100, print the corresponding value in itemsList, followed by a space. Ex: If keysList = {42, 105, 101, 100} and itemsList = {10, 20, 30, 40}, print: 20 30 Since keysList.at(1) and keysList.at(2) have values greater than 100, the value of itemsList.at(1) and itemsList.at(2) are printed. #include <iostream>#include <vector>using namespace std; int main() {const int SIZE_LIST = 4;vector<int> keysList(SIZE_LIST);vector<int> itemsList(SIZE_LIST);unsigned int i; for (i = 0; i < keysList.size(); ++i) {cin >> keysList.at(i);} for (i = 0; i < itemsList.size(); ++i) {cin >> itemsList.at(i);} /* Your solution goes here */ cout << endl; return 0;} Please help me with this problem using c++.arrow_forward
- Your task: Remove any word that does not start with a capital letter. For instance, for the input text of "Hello, 2022 world!", we should get "Hello, 2022 !".arrow_forwardHashMap is a parameterized class. List those of its methods that depend on the types used to parameterize it. Do you think the same type could be used for both of its parameters?arrow_forwardWe have two classes; these classes are "Car" and "Price".The "car" class is a class that keeps the id and price of the car.If the "Price" class is, there will be get / set methods for the segment of the fee (For example Y segment Z segment), the number of cars, and the "Car" class list.In the "Price" class, there should be a print method to add / remove cars to the list and find the ids of Vehicles whose segments are equal to X.The segments are as follows. 0$ -15999$ -> Y Segment16000$-24999$ -> Z Segment25000$-50000$ -> T Segment It is necessary to use "Single Linked List".The program should be written in JAVA.arrow_forward
- Below is the code for a Time class that has both an equals method and a hashCode method; however, the body of the hashCode method is missing. In the text box, write the code you would put inside the body of the hashCode method. Remember that a hashCode with no collisions is better than a hashCode that has collisions and a hashCode with no gaps in the values is better than a hashCode that has gaps. public class Time { private int hour; // A number between 1 and 12 private int min; // A number between 0 and 59 private boolean pm; // True if the time is pm. public Time(int hour, int min, boolean pm) { this.hour = hour; this .min = min; this.pm = pm; } public int getHour() { return hour; } public int getMin() { return min; } public boolean isPM() { return pm == true; } public boolean isAM() { return pm == false; } public boolean equals(Object obj) { if (this == obj) return true; if (obj ==…arrow_forwardBelow is the code for a Time class that has both an equals method and a hashCode method; however, the body of the hashCode method is missing. In the text box, write the code you would put inside the body of the hashCode method. Remember that a hashCode with no collisions is better than a hashCode that has collisions and a hashCode with no gaps in the values is better than a hashCode that has gaps. public class Time { private int hour; // A number between 1 and 12 private int min; // A number between 0 and 59 private boolean pm; // True if the time is pm. public Time(int hour, int min, boolean pm) { this.hour = hour; this .min = min; this.pm = pm; } public int getHour() { return hour; } public int getMin() { return min; } public boolean isPM() { return pm == true; } public boolean isAM() { return pm == false; } public boolean equals(Object clock) { if (this == clockj) return true; if…arrow_forwardPlease answer the question in the screenshot. The language used is Java.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