Data Structures and Algorithms in Java
Data Structures and Algorithms in Java
6th Edition
ISBN: 9781119278023
Author: Michael T. Goodrich; Roberto Tamassia; Michael H. Goldwasser
Publisher: Wiley Global Education US
bartleby

Concept explainers

Question
Book Icon
Chapter 1, Problem 9R
Program Plan Intro

Removing all the punctuations from a string

Program plan:

  • Create a class StringBuilder to remove all the punctuation stored in a string.
    • In main() function,
      • Initially, assign the original string in variable.
      • Then, invoke the removeIt()function to remove all the punctuation in a string and store the final value in original string.
      • Display the string after removing the punctuation in console screen.
    • In the method removeAt(),
      • It passes  input parameter “s” to check whether the character contains punctuation in the string. If yes, then it removes all the punctuation stored in the string “s”.
      • For loop read all the characters from a sentence until the condition leads to false.
      • Then, it calls the function ok() and check whether the character at “j” position matches with the character or not.
        • If the result returns the Boolean value false, then delete the character at the specified position in “j” otherwise store the character using Tostring() method in “s” variable.
    • In the method ok(),
      • It passes input parameter “i” to check whether the character in the sentence matches with the corresponding ASCII values.
        • If yes, then it returns the Boolean value true otherwise it return false.

Blurred answer
Students have asked these similar questions
Write an application that reads a five-letter word from the user and produces every possible three-letter string that can be derived from the letters of that word. For example, the three-letter words produced from the word “bathe” include “ate,” “bat,” “bet,” “tab,” “hat,” “the” and “tea.”
WRITE IN JAVA USING JOptionPane.showInputDialog  Write a program that reads a sentence as input and converts each word to “Pig Latin”. In one version of Pig Latin, you convert a word by removing the first letter, placing that letter at the end of the word, and then appending “ay” to the word. Here is an Example: English:      I SLEPT MOST OF THE NIGHT Pig Latin:   IAY LEPTSAY OSTMAY FOAY HETAY IGHTNAY EXAMPLE:
FOR JAVA Write a method that takes a String array and an integer as parameters and prints the Strings in the array whose length is greater than the second parameter.

Chapter 1 Solutions

Data Structures and Algorithms in Java

Knowledge Booster
Background pattern image
Computer Science
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
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education