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
makvit [3.9K]
4 years ago
10

Write a function "doubleChar(" str) which returns a string where for every character in the original string, there are two chara

cters.

Computers and Technology
1 answer:
Dmitry [639]4 years ago
7 0

Answer:

//Begin class definition

public class DoubleCharTest{

   

   //Begin the main method

    public static void main(String [ ] args){

       //Call the doubleChar method and pass some argument

       System.out.println(doubleChar("There"));

    }

   

    //Method doubleChar

    //Receives the original string as parameter

    //Returns a new string where for every character in

    //the original string, there are two characters

    public static String doubleChar(String str){

        //Initialize the new string to empty string

       String newString = "";

       

        //loop through each character in the original string

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

            //At each cycle, get the character at that cycle

            //and concatenate it with the new string twice

           newString += str.charAt(i) + "" + str.charAt(i);

        }

        //End the for loop

       

        //Return the new string

       return newString;

       

    } //End of the method

   

} // End of class declaration

<h3>Sample Output:</h3>

TThheerree

<h3>Explanation:</h3>

The code above has been written in Java and it contains comments explaining each line of the code. Kindly go through the comments. The actual lines of executable codes have been written in bold-face to differentiate them from comments.

A sample output has also been given.

Snapshots of the program and sample output have also been attached.

You might be interested in
The process of identifying and removing logical errors and runtime errors is called ..............
9966 [12]
The process of finding and eliminating errors is called debugging.

Hope that helps
VexPlayz
6 0
3 years ago
Read 2 more answers
Suppose Alice and Bob are sending packets to each other over a computer network. SupposeTrudy positions herself in the network s
Elden [556K]

<u>Explanation:</u>

  • can observe the contents of all the packets sent and even modify the content.
  • can prevent packets sent by both parties from reaching each other.

From a network security standpoint, since we are told that Trudy <em>"</em><em>positions herself in the network so that she can capture all the packets sent", </em>it, therefore implies that the communication between Alice and Bob is vulnerable to modification and deletion.

6 0
3 years ago
(PLEASE HELP!! I'll award brainiest!!)
Bas_tet [7]

Answer:

Repair

Have a good day

3 0
3 years ago
Read 2 more answers
Question 6 (2 points)
OLga [1]

Answer:

It is all of the above

Explanation:

Technology is seen everywhere like in DVD player , a new medical treatment and skills needed to purify water

4 0
3 years ago
Account numbers sometimes contain a check digit that is the result of a mathematical calculation. The inclusion of the digit in
marishachu [46]

Answer:

using System;

class CheckDigit

{

public static void Main (string[] args)

{ //Accepting value from user

Console.WriteLine ("Enter a four-digit account number");

int acc = Convert.ToInt32(Console.ReadLine());

int d=acc%10; //extracting the last digit

acc=acc/10; //having the first three digit

if(acc % 7 == d) //checking and displaying

Console.WriteLine ("Valid Account Number");

else

Console.WriteLine ("Invalid Account Number");

}

}

Explanation:

3 0
3 years ago
Other questions:
  • How many bits are required to address a 1mx8 main memory if main memory is byte addressable?
    6·1 answer
  • What happens to the data in rom when the power is turned off?
    10·1 answer
  • A computer that stores and distributes newsgroup messages is called a newsreader.
    13·1 answer
  • If a person was on board a hypersonic airplane what do you think they would be able to see as they look out a window looking in
    13·2 answers
  • What type of USB connector is always plugged into the computer to connect in external device
    14·1 answer
  • Sukhi needs to insert a container into her form to collect a particular type of information. Which object should she insert?
    6·1 answer
  • One of the most common causes of fires in the home and workplace is: a. All of the answer choices b. Arson c. Candle d. Faulty e
    6·1 answer
  • In a particular jurisdiction, taxi fares consist of a base fare of $4.00, plus $0.25 for every 140 meters traveled. Write a func
    11·1 answer
  • True or False: <br> The object reference can be used to polymorphically store any class in Java.
    13·1 answer
  • What are pixels?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!