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
Alex73 [517]
3 years ago
8

Write method reverseString, which takes a string str and returns a new string with the characters in str in reverse order. For e

xample, reverseString("ABCDE") should return "EDCBA".
Complete the reverseString method below by assigning the reversed string to result.

/** Takes a string str and returns a new string

* with the characters reversed.

*/

public static String reverseString(String str)

{

String result = "";

return result;

}
Computers and Technology
1 answer:
son4ous [18]3 years ago
3 0

Answer:

The method written in Java is as follows:

public static String reverseString(String str){

    String result = "";

    int lentt = str.length();

    char[] strArray = str.toCharArray();

       for (int i = lentt - 1; i >= 0; i--)

           result+=strArray[i];

    return result;

}

Explanation:

This defines the method

public static String reverseString(String str){

This initializes the result of the reversed string to an empty string

    String result = "";

This calculates the length of the string

    int lentt = str.length();

This converts the string to a char array

    char[] strArray = str.toCharArray();

This iterates through the char array

       for (int i = lentt - 1; i >= 0; i--)

This gets the reversed string

           result+=strArray[i];

This returns the reversed string            

    return result;

}

<em>See attachment for full program that includes the main method</em>

Download txt
You might be interested in
Each piece of evidence that is collected should be placed in a separate container true or false
alexandr402 [8]
Yes this is true . But evidence is better when it’s true
4 0
3 years ago
The ____________ is the number of rectangles an image has in a square inch.
miv72 [106K]
D size




Read more




































Hope,this helped
7 0
3 years ago
Read 2 more answers
What are some of the functions in the Consolidate dialog box? Check all that apply.
goblinko [34]

Answer:

sum average and count is the answer

5 0
3 years ago
In your code editor, there is some code meant to output verses of the song "old macdonald had a farm. " when the code is working
iris [78.8K]

Using the knowledge in computational language in python it is possible to write a code that  meant to output verses of the song "old macdonald had a farm.

<h3>Writting the code:</h3>

def main():

   # Make a list containing animals and sounds.

   #     Element n is the animal and n+1 is its sound.

   animals = ['cow', 'moo', 'chicken', 'cluck', 'dog', 'woof', 'horse', 'whinnie', 'goat', 'blaaah']

   # For each animal/sound pair

   for idx in range(0, len(animals), 2):

       # Call song(), passing the animal/sound pair as parameters.

       song(animals[idx], animals[idx+1])

       print()

# song():

#   animal and sound are arguments

def song(animal, sound):

   # Call firstLast() for first line of song

   firstLast()

   # Call middleThree() for middle three lines, passing animal and sound

   middleThree(animal, sound)

   # Call firstLast() for last line of song

   firstLast()

# firstLast():

def firstLast():

   # Print "Old MacDonald had a farm, Ee-igh, Ee-igh, Oh!"

   print("Old MacDonald had a farm, Ee-igh, Ee-igh, Oh!")

# middleThree():

#   animal and sound are arguments

def middleThree(animal, sound):

   # Print middle three lines of song with passed animal and sound.

   print('And on that farm he had a {0}, Ee-igh, Ee-igh, Oh!'.format(animal))

   print('With a {0}, {0} here and a {0}, {0} there.'.format(sound))

   print('Here a {0}, there a {0}, everywhere a {0}, {0}.'.format(sound))

main()

See more about python at  brainly.com/question/18502436

#SPJ1

5 0
1 year ago
Website reputation is an important part of page quality (PQ) rating. Reputation can justify the Highest rating and the Lowest ra
Sergio039 [100]

Answer:

The given statement is false.

Explanation:

  • A Website reputation seems to be a built-in feature or tool. It retains knowledge about users, through visiting pages. The committed resources for this site depending on either the website as well as the basic details about its design.
  • The reputation including its Website has been used to strengthen the safety of phishing attacks or malicious content.

Therefore the solution given above is the right one.

4 0
3 years ago
Other questions:
  • If an ARQ algorithm is running over a 40-km point-to-point fiber optic link then:
    12·1 answer
  • Compare GBN, SR, and TCP (no delayed ACK). Assume that the timeout values for all three protocols are sufficiently long such tha
    7·1 answer
  • Computer program allowing the computer to communicate<br> with a hardware device
    13·1 answer
  • Ada lovelace designed the first computer
    7·1 answer
  • A computer is a multipurpose device that accepts input, processes data, stores data, and produces output, all according to a ser
    9·1 answer
  • What number system do people in America use?
    10·2 answers
  • 31
    10·1 answer
  • How do we “read” and “write” in MAR and MDR memory unit, please help I am very confused :)
    10·1 answer
  • What is the output of the following code?<br> print (12 // 6)
    12·1 answer
  • Three types of query​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!