17. An array of String objects, words, has been properly declared and initialized. Each element of words contains a String consisting of lowercase letters (a-z). Write a code segment that uses an enhanced for loop to print all elements of words that end with "ing" As an example, if words contains {"ten", "fading", "post", "card", "thunder", "hinge", "trailing", "batting"), then the following output should be produced by the code segment. fading trailing batting Write the code segment as described above. The code segment must use an enhanced for loop to eam full credit. {
17. An array of String objects, words, has been properly declared and initialized. Each element of words contains a String consisting of lowercase letters (a-z). Write a code segment that uses an enhanced for loop to print all elements of words that end with "ing" As an example, if words contains {"ten", "fading", "post", "card", "thunder", "hinge", "trailing", "batting"), then the following output should be produced by the code segment. fading trailing batting Write the code segment as described above. The code segment must use an enhanced for loop to eam full credit. {
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter16: Searching, Sorting And Vector Type
Section: Chapter Questions
Problem 23SA
Related questions
Question
Expert Solution
Step 1
Algorithm:
Print words ending with "ing"
- START
- Declare and initialize an array of string objects called "words".
- Use an enhanced for loop to iterate through each element of the array of "words".
- In the loop, check if the current element (word) ends with "ing" using the endsWith method.
- If the word ends with "ing", print the word.
- Repeat steps 3 and 4 for all elements in the array.
- End the algorithm.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
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.Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning