Data Structures and Algorithms in Java
6th Edition
ISBN: 9781119278023
Author: Michael T. Goodrich; Roberto Tamassia; Michael H. Goldwasser
Publisher: Wiley Global Education US
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
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.
- It passes input parameter “i” to check whether the character in the sentence matches with the corresponding ASCII values.
- In main() function,
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
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…
In java can you help with parts that are missing
Email- date: Date- subject: String- urgent: boolean+ Email(date:Date,urgent:boolean,subject:String)+ getDate(): Date+ setDate(date: Date): void+ getSubject(): String+ setSubject(subject:String): void+ isUrgent(): boolean+ setUrgent(urgent: boolean): void+ toString(): String
public class Email
{
private Date date;
private String subject;
privatebooleanurgent;
public Email()
{
}
public Email(Date date, booleanurgent, String subject)
{
this.date = date;
this.urgent = urgent;
this.subject = subject;
}
public Date getDate()
{
returndate;
}
publicvoid setDate(Date date)
{
this.date = date;
}
public String getSubject()
{
returnsubject;
}
publicvoid setSubject(String subject)
{
this.subject = subject;
}
publicboolean isUrgent()
{
returnurgent;
}
publicvoid setUrgent(booleanurgent)
{
this.urgent = urgent;
}
@Override
public String toString()
{
return"Email [date=" + date + ", subject=" + subject + ", urgent=" + urgent +…
Java
Chapter 1 Solutions
Data Structures and Algorithms in Java
Ch. 1 - Prob. 1RCh. 1 - Suppose that we create an array A of GameEntry...Ch. 1 - Write a short Java method, isMultiple, that takes...Ch. 1 - Write a short Java method, isEven, that takes an...Ch. 1 - Write a short Java method that takes an integer n...Ch. 1 - Write a short Java method that takes an integer n...Ch. 1 - Write a short Java method that takes an integer n...Ch. 1 - Write a short Java method that counts the number...Ch. 1 - Prob. 9RCh. 1 - Prob. 10R
Ch. 1 - Modify the CreditCard class from Code Fragment 1.5...Ch. 1 - Prob. 12RCh. 1 - Modify the declaration of the first for loop in...Ch. 1 - Prob. 14CCh. 1 - Write a pseudocode description of a method for...Ch. 1 - Write a short program that takes as input three...Ch. 1 - Write a short Java method that takes an array of...Ch. 1 - Prob. 18CCh. 1 - Write a Java program that can take a positive...Ch. 1 - Write a Java method that takes an array of float...Ch. 1 - Write a Java method that takes an array containing...Ch. 1 - Prob. 22CCh. 1 - Write a short Java program that takes two arrays a...Ch. 1 - Modify the CreditCard class from Code Fragment 1.5...Ch. 1 - Modify the CreditCard class to add a toString()...Ch. 1 - Write a short Java program that takes all the...Ch. 1 - Write a Java program that can simulate a simple...Ch. 1 - A common punishment for school children is to...Ch. 1 - The birthday paradox says that the probability...Ch. 1 - (For those who know Java graphical user interface...
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
- Create a subroutine that takes a noun-verb-object straightforward phrase and breaks it down into its component components. For instance, the phrase "Mary walked the dog" is broken down into the following:Noun: MaryVerb: walkedObject: the dogBoth StringBuilder objects and String objects should be compatible with this method.arrow_forwardWrite a java class method named addQuotes that takes one parameter of type String. The method should return a string that's indentical to it's argument, but with a double quote character added at the beginning and end of the string.arrow_forwardIn java Consider strings that can be split so that their first half is the same as their second half (ignoring blanks, punctuation, and case). For example, the string "booboo" can be split into "boo" and "boo". Another example is "hello, hello". After ignoring blanks and the comma, the two halves of the string are the same. However, the string "rattan" has unequal halves, as does the string "abcab". Add a method public static boolean check(String s) to the class Array Queue (function must be in the file ArrayQueue.java) that returns true when s has the property above and false otherwise. must use methods from Queuelnterface.java and ArrayQueue.java. Do not use stacks or recursion. First - In this problem, we will add new methods to the class Array Queue Suppose that we want to add a method to a class of queues that will splice two queues together. This method adds to the end of a queue all items that are in a second queue (making the second queue empty). The header of the method could…arrow_forward
- Java - Encapsulation A rectangle can be formed given two points, the top left point and the bottom right point. Assuming that the top left corner of the console is point (0, 0), the bottom right corner of the console is point (MAX, MAX) and given two points (all “x” and “y” coordinates are positive), you should be able to draw the rectangle in the correct location, determine if it is a square or a rectangle, and compute for its area, perimeter and center point. To be able to do this, you should create a class Point (that has an x-coordinate and a y-coordinate). Also, create another class called Rectangle. The Rectangle should have 2 points, the top left and the bottom right. You should also implement the following methods for the Rectangle: display() - draws the rectangle on the console based on the samplearea() - computes and returns the area of a given rectangleperimeter() - computes and returns the perimeter of a given rectanglecenterPoint() - computes and returns the center point…arrow_forwardIn java write a complete Java program that displays all the numbers, from 1 to 200, that are divisible by both 2 and 3. Numbers are separated by exactly one space.arrow_forwardCreate a subroutine that breaks down basic noun-verb-object sentences into their component parts. For instance, the phrase "Mary walked the dog" is broken down into the following: Noun: MaryVerb: walkedObject: the dog Both StringBuilder objects and String objects should be compatible with this method.arrow_forward
- JAVA Write a program that formats the telephone number. The class, telephone.java, receives the telephone number and format it. For example, it receives a phone number "9195551212". And then change to (919)555-1212. You must use methods in StringBuilder class.arrow_forwardWrite a program in java language to Use String methods to write a program called TitleCase.java that prompts the user to enter his First Last name. Covert this name into Upper and Lower Case. Give source code and output alsoarrow_forwardA class may occasionally be dependent upon itself. In other words, an object of one class engages in communication with an object of the same class. To do this, a method of the class can take an object of the same class as a parameter.An illustration of this scenario is the concat method of the String class. One String object calls the method, while another String object is supplied as an argument. Here's an illustration:str2 = str1.concat;The String object (str1) that executes the method adds its characters to the String (str2) that was supplied as a parameter. As a result, a fresh String object is produced and saved as str3. Write Java code to put the circumstances given into effect.arrow_forward
- in java, make a code that returns the values that are asked within the imagearrow_forwardUsing java on Eclipsearrow_forwardIn some cases, a class depends on itself. That is, an object of one class interactswith another object of the same class. To accomplish this, a method of the classmay accept as a parameter an object of the same class.The concat method of the String class is an example of this situation. Themethod is executed through one String object and is passed another String object as a parameter. Here is an example:str3 = str1.concat(str2);The String object executing the method (str1) appends its characters to thoseof the String passed as a parameter (str2). A new String object is returned asa result and stored as str3. Write java code to implement given conditionsarrow_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