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
icon
Related questions
Question
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"
"batting"), then the following output should be produced by the code segment.
"hinge", "trailing",
fading
trailing
batting
Write the code segment as described above. The code segment must use an enhanced for loop to eam full credit.
Transcribed Image Text: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" "batting"), then the following output should be produced by the code segment. "hinge", "trailing", fading trailing batting Write the code segment as described above. The code segment must use an enhanced for loop to eam full credit.
Expert Solution
Step 1

Algorithm:

Print words ending with "ing"

  1. START
  2. Declare and initialize an array of string objects called "words".
  3. Use an enhanced for loop to iterate through each element of the array of "words".
  4. In the loop, check if the current element (word) ends with "ing" using the endsWith method.
  5. If the word ends with "ing", print the word.
  6. Repeat steps 3 and 4 for all elements in the array.
  7. End the algorithm.
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Array
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning