1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Delicious77 [7]
3 years ago
14

I need help to make this code to make it remove all instances of the specified letter from the original sentence

Computers and Technology
1 answer:
Agata [3.3K]3 years ago
5 0
Here is my solution. I did the following:

- changed the setRemover into a constructor, since the comment seems to hint that that is expected.
- changed the lookFor type into a String, so that it can work with the string replace overload. That's convenient if you want to replace with an emtpy string. The char type won't let you do that, you can then only replace one char with another.
- Added a static Main routine to use the class.

import java.lang.System.*;

public class LetterRemover 
{
   private String sentence;
   private String lookFor;

   public LetterRemover() {}
   
   // Constructor
   
   public LetterRemover(String s, char rem)
   {
       sentence = s;
       lookFor = String.valueOf(rem);
   }
   
   public String removeLetters()
   {       
       String cleaned = sentence.replace(lookFor, "");       
       return cleaned;
   }
   
   public String toString()
   {
       return sentence + " - letter to remove " + lookFor;
   }

   public static void main(String[] args) 
   {
        LetterRemover lr = new LetterRemover("This is the tester line.", 'e');
        System.out.println(lr.toString());
        String result = lr.removeLetters();        
        System.out.println("Resulting string: "+result);
   }
}

You might be interested in
TCO 10) Voice packets could experience a significant _____ delay in routers and switches when sharing a network with data traffi
bonufazy [111]

This delay in routers is what we called Packetization delay or also called Accumulation delay. Packetization delay is the time required for the information to pass on the wires. The data rate of the links that passes thru the wires cause the delay.

8 0
3 years ago
Write any four common hardware devices​
marishachu [46]

Answer:

Input devices: For raw data input.

Processing devices: To process raw data instructions into information.

Output devices: To disseminate data and information.

Storage devices: For data and information retention.

8 0
3 years ago
Cách soạn thảo văn bản trên word
pickupchik [31]

Answer:

Did you mean How to edit text on word? There are 2 word, Microsoft Word Office and WordPad. The step I give you below is for both.

Explanation:

Steps to edit text on word

Step-1: Select the text you want to edit.

Step-2: Click on Home Tab.

Step-3: Select the style(s) you want to edit from the Font group

8 0
3 years ago
The CPI is a measure of the overall cost of the goods and services bought by a. a typical consumer, and the CPI is computed and
Akimi4 [234]

Answer:

a typical consumer, and the CPI is computed and reported by the Bureau of Labor Statistics.

Explanation:

The CPI is a measure of the overall cost of the goods and services bought by a typical consumer , and the CPI is computed and reported by the Bureau of labor statistics. Hence, option C is correct.

5 0
3 years ago
A company wants to ensure that the validity of publicly trusted certificates used by its web server can be determined even durin
Natali [406]

Answer: OCSP

Explanation:

Ocsp(online certificate status protocol) is used to maintain the security status of the server and also to determine the status of SSL/TLS certificates used by the webserver.

5 0
3 years ago
Other questions:
  • Values that are sent into a function are called _________.<br><br> Program Output
    7·1 answer
  • The default case is required in the switch selection statement.
    12·1 answer
  • I have all the points to level up to virtuoso, but it hasn't yet does anyone know when it will?
    9·1 answer
  • Which component is a part of the central processing unit (CPU) of a computer
    11·2 answers
  • Which of the following statements is true about a file stream?
    5·1 answer
  • The data-linking feature that allows Internet users to skip directly from a highlighted word to a related file in another comput
    12·2 answers
  • Which technique is best suited to create technical drawings?
    10·1 answer
  • You are implementing a RAID storage system and have found a system with eight 100 GB drives. How much storage space will you hav
    5·1 answer
  • Why can videos be streamed from the cloud to a computer with no loss in
    5·2 answers
  • The main components of a computer ar a hardware and software b) disc and monitor c) system and unit d) communication devices. ​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!