Data Structures and Algorithms in Java
Data Structures and Algorithms in Java
6th Edition
ISBN: 9781118771334
Author: Michael T. Goodrich
Publisher: WILEY
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:
Implement your own indexOf(String s) and lastIndexOf(String s) methods without using the built-in ones available in Java String class. Complete the following program://course: CSC190//project: Lab 12//date: (today’s date)//author: (your name)//purpose:import java.util.Scanner;class MyString {String s;   //default constructor which sets s to a null string   //your code here   //additional constructor which sets s to the string passed from the caller   //your code here   //get and set methods for s   //your code here   //return the index within s of the first occurrence of str.   //return -1 when str is not found on s.   //if s = "aabababb", s = "aba", return 1   //if s = "aabababb", s = "abaa", return -1   int indexOf(String str) {      //your code here}   //return the index within s of the last occurrence of str.   //return -1 when s is not found on str.   //if s = "aabababb", s = "aba", return 3   //if s = "aabababb", s = "abaa", return -1   int lastIndexOf(String s) {      //your…

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