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
What security weaknesses/vulnerabilities exist in Wireless local area network device hardware and software?
AfilCa [17]

Answer:

Explanation:

There are many weaknesses/vulnerabilities, some of which are the following...

Default Network Hardware, many individuals will go out and buy a new router and install it in their home. These devices come with a preset configuration including a preset security password which is many times a default password used for every router of the same model. This can be easily obtained by anyone who can then access the network.

Access Point hacking, an experienced individual can use a packet sniffer to detect the SSID that is frequently sent from the router in order to create an access point to be able to access the network.

WEP encryption is another vulnerability. These are very low security passwords that can be cracked using different software in a short period of time.

These are some of many vulnerabilities that wireless local networks have, but there are also many precautions and security measures that can be taken to prevent them.

7 0
3 years ago
File names should describe what is in the file in a few words
JulijaS [17]

Answer

File names should describe the content of the file.

Explanation

File names are set of words  which are used to uniquely identify computer files which are stored in a file system. This helps one to know the contents of the file which you want to find. When you name these file names you use necessary characters you use descriptive words so that you dont have hard times when searching for them. The naming also is determined by the file system you are using because different systems impose different restrictions on the length of the file names and the allowed characters within file names.

3 0
3 years ago
1. Data in a smart card can be erased
Ostrovityanka [42]

Answer:

false

true

false

true

true

5 0
3 years ago
Read 2 more answers
What happens once the Insert tab is used in PowerPoint to insert a chart into a presentation?
nordsb [41]

Answer:

•The user can edit the chart directly. hoped i;m right

Explanation:

6 0
3 years ago
A cookie recipe calls for the following ingredients: • 1.5 cups of sugar • 1 cup of butter • 2.75 cups of flour The recipe produ
True [87]

The program that asks the user how many cookies they want to make and then displays the number of cups of each ingredient is corresponds to the ingredients mentioned above.

<h3>Further explanation</h3>

Python is a general-purpose programming language. We want to write a python program that asks the user how many cookies they want to make and then displays the number of cups of each ingredient.

48 cookies = 1.5 cups of sugar + 1 cup of butter + 2.75 cups of flour, so:

def main():

   cookies = float(input("How many cookies would you like to make?\n>"))

   sugar = (1.5 * cookies) / 48.0

   butter = cookies / 48

   flour = (2.75 * cookies) / 48

   print("To make ", cookies, " cookies, you will need:\n", \

         format(sugar, '.2f'), " cups of sugar\n", \

         format(butter, '.2f'), " cups of butter\n", \

         format(flour, '.2f'), " cups of flour", sep='')

   redoQuery()  

def redoQuery():

   yn = input("Would you like to check another batch size? (y/n)\n>")

   if yn == 'y':

       main()

   elif yn =='n':

       exit()

   else:

       print("Please enter only a lowercase \'y\' or lowercase \'n\'," \

             "then press enter")

       redoQuery()

main()

The run program is shown in the attachment below.

<h3>Learn more</h3>

1. Learn more about python https://brainly.in/question/8049240

 

<h3>Answer details</h3>

Grade:  9

Subject: Computers and Technology

Chapter:  programming with python

Keywords: python

4 0
4 years ago
Other questions:
  • What is the outlined area called?
    6·1 answer
  • The method of loci, peg-word system, substitute word system, and method of word association are all examples of _____.
    8·1 answer
  • 5. The shell of a document that may be used over and over in desktop publishing is called a
    14·2 answers
  • What are the functions of online gaming communities?
    12·1 answer
  • The part of the computer that contains the brain or the Central Park nursing unit is also known as
    10·1 answer
  • What does it mean to catch an exception?
    8·1 answer
  • A group of users is unable to connect to the network. When testing several of the PCs and issuing the command ipconfig, the tech
    10·1 answer
  • I’ll mark brainliest if correct
    10·1 answer
  • Working mechanism of computer ​
    10·1 answer
  • True or false: all blockchains are programmed to have the same block time (confirmation time) as each other.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!