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
Alexandra [31]
2 years ago
7

Write a method named removeDuplicates that accepts a string parameter and returns a new string with all consecutive occurrences

of the same character in the string replaced by a single occurrence of that character. For example, the call of removeDuplicates("bookkeeeeeper") should return "bokeper" .
Computers and Technology
1 answer:
Nitella [24]2 years ago
7 0

Answer:

//Method definition

//Method receives a String argument and returns a String value

public static String removeDuplicates(String str){

       //Create a new string to hold the unique characters

       String newString = "";

       

       //Create a loop to cycle through each of the characters in the

       //original string.

       for(int i=0; i<str.length(); i++){

           // For each of the cycles, using the indexOf() method,

           // check if the character at that position

           // already exists in the new string.

           if(newString.indexOf(str.charAt(i)) == -1){

               //if it does not exist, add it to the new string

               newString += str.charAt(i);

           }  //End of if statement

       }   //End of for statement

       

       return newString;   // return the new string

   }  //End of method definition

Sample Output:

removeDuplicates("bookkeeeeeper") => "bokeper"

Explanation:

The above code has been written in Java. It contains comments explaining every line of the code. Please go through the comments.

The actual lines of codes are written in bold-face to distinguish them from comments. The program has been re-written without comments as follows:

public static String removeDuplicates(String str){

       String newString = "";

       

       for(int i=0; i<str.length(); i++){

           if(newString.indexOf(str.charAt(i)) == -1){

               newString += str.charAt(i);

           }

       }

       

       return newString;

   }

From the sample output, when tested in a main application, a call to removeDuplicates("bookkeeeeeper") would return "bokeper"

You might be interested in
structured analysis is called a(n) _____ technique because it focuses on processes that transform data into useful information.
zzz [600]

Answer:

Process - centered technique

Explanation:

Process - centered technique -

It is the method , where the useless or waste data is converted to some useful information , is referred to as process - centered technique .

This conversion process requires some activities , like  maintenance/support  , implementation , design , analysis and  planning .

Hence , from the given information of the question,

The correct option is Process - centered technique .

4 0
3 years ago
What is cloud based LinkedIn Automation?
Zielflug [23.3K]

Answer:

The cloud-based LinkedIn automation tool makes life easier for you by automating functions like sending connection requests, liking and commenting on posts, sending customized messages, and much more.

6 0
2 years ago
Read 2 more answers
What are some reasons DNS is necessary? Check all that apply. A. It maps local addresses to simple names without editing hosts f
dsp73
Domain Name Servers (DNS) are certainly necessary for easy access of resources across a network. The applicable options of the above are A and B - below are explanations as to why.

A: Computers generally are set to automatically obtain DNS information from the network they are connected to or can be pointed to a specific DNS server. This allows for records of where resources (network attach storage devices, other computers on local network, or even website server details) are located on a “master” kind of list so that the local machine’s host file does not have to be routinely updated to contain new addresses.

B: DNS, as explained partially by the answer to A, maintains a type-able or “human readable” domain name for the actual server’s IP address so we don’t have to memorize or keep a list of IPs for where we want to visit on the web (although, Google’s 8.8.8.8 IP address does make it easy). It shows an association between a name/domain name and an IP address so that we can enter something simple (Google.com) and the computer knows where to go (the server at IP address 8.8.8.8) so it can show you the content you want to see.

C: DNS would only simplify remote access if your were attempting LAN (Local Area Network) remote access of another computer on your network. DNS would not make it easier for remote access of a computer on the internet, as most DNS used in non-commercial settings are created and maintained by third-parties that will not put a specific record for one of your computers in it - not that you would want them to either, since it could lead to an open cyber attack.

D: Network throughput is a fancy phrase for network speed. It could be possible that different DNS servers could process requests faster than others, but it is not likely to increase network speed on the whole as navigating via IP or DNS records will be relatively the same speed.
3 0
2 years ago
What type of software controls the hardware of a computer? Desktop publishing software Spreadsheet applications Groupware applic
Hatshy [7]
It's most likely the Operating System Applications
4 0
3 years ago
Ejercicio 12:<br> Convierte a binario los números hexadecimales siguientes: 7A5D.., 1010<br> ..
Natasha_Volkova [10]

Answer:

0111 1010 0101 1100

Explanation:

7 A 5 D

0111 1010 0101 1100

3 0
2 years ago
Other questions:
  • The ____ command displays the last 10 lines of a text file.
    5·1 answer
  • Technologies have advanced to allow computer chips to be placed in almost anything and to be connected to a network almost anywh
    8·1 answer
  • Angela recently purchased a new Android smartphone. While purchasing the phone, Angela was told that she would need to set up a
    11·1 answer
  • What method is used to manage contention-based access on a wireless network?
    7·1 answer
  • Match the file extensions to the file types. Some file types may be used more than once.
    11·1 answer
  • In an income statement subtracting the cost of goods sold from the net sales provides the?
    11·1 answer
  • Write the definition of a function named fscopy. This function can be safely passed two fstream objects, one opened for reading,
    11·1 answer
  • Given the arra
    15·1 answer
  • The physical layer of the OSI model is not foundational to any of the other layers. True or False
    8·1 answer
  • Vivek wants to save the data about his grocery store in a single table. Which among the following type of databases is used in t
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!