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
The technology Herman Hollerith created in the 1880s began the modern-day data processing function in computers.
adell [148]

Answer:

Punch Card Machine

Explanation:

The punch cards or the punched cards are also termed as the Hollerith cards or we also know them as the IBM cards. And they happen to be the paper cards where holes can be punched with the help of the hands or with the help of the machine for representing the computer instructions or data. And these were used on quite a large scale for inputting the data when we talk of the early computers. And this technology was developed by the Herman Hollerith.

7 0
4 years ago
Please help me. i will mark you brailiest
Stolb23 [73]

Answer:

Simple, really

Explanation:

3Rd one is pretty easy, all you have to do is read closely.

3 0
3 years ago
What is another name for an unmanaged switch?
Natalka [10]

Answer:

The answer is "Plug and play".

Explanation:

A switch with minimum debugging tools for log-and-play simplicity and also no IP address. The Unmanaged switches are cost-effective and also have limited power, and other choices are not correct, which can be described as follows:

  • Fast Ethernet provides 10 to 100 Mbps speeds, that's why it is not correct.
  • Gigabit provides bandwidth, which is up to 1 Gbps speed, and it is 10 times faster than Ethernet Fast, that's why it is wrong.
  • The trunk provides the link design that's why it is not correct.
7 0
3 years ago
Each array in Java has a public field named ________ that contains the number of elements in the array.
Helen [10]

Answer:

length.

Explanation:

length variable determines the size of the array or the number of elements in the array.length variable is a final variable.It is a public field.It is only applicable for array it is not applicable for strings.It is also used to directly access the field member of the array.So we conclude that the answer is length.

7 0
4 years ago
Without any formal planning, the president of a software company remarks in a speech that new technologically advanced software
ahrayia [7]

Answer:

<em>Imposed project deadlines.</em>

Explanation:

The term of project management imposed deadline<em> refers mainly to the calendar-based dividing line used to determine a fixed time or date on which the project management team has projected and/or developed that the particular schedule of work and/or schedule of work events.</em>

6 0
4 years ago
Other questions:
  • What are the advantages of homogenation
    5·1 answer
  • The region which satisfies all of the constraints in graphical linear programming is called the:
    8·1 answer
  • What is a method to exit wordprocessing software
    14·1 answer
  • What’s the purpose of balancing or monitoring your checking account?
    12·2 answers
  • What was the first video game ever invented
    11·2 answers
  • Write a function findWithinThreshold that identifies the elements of a given array that are inside a threshold value. Takes the
    13·1 answer
  • Multiple Choice: We have been assigned the task of developing a software testing tool (tester) that can assess reachability of s
    11·1 answer
  • How do professionals address their problems?
    14·2 answers
  • How to Calculate the area of a rectangle in python
    13·2 answers
  • Trying to make the baseplate red and turn off can collide then the game waits 5 seconds and turns on can collide, making the bas
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!