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
Gemiola [76]
2 years ago
13

Debug the recursive reverseString method, which is intended to return the input String str reversed (i.e. the same characters bu

t in reverse order).
Use the runner class to test this method but do not write your own main method or your code will not be graded correctly.
public class U10_L2_Activity_One
{
public static String reverseString(String str)
{
if (str.length() < 0)
{
return str;
}
s = reverseString(str.substring(2)) + str.substring(0,1);
}
}
Runner's code (don't change):
import java.util.Scanner;
public class runner_U10_L2_Activity_One
{
public static void main(String[] args)
{
System.out.println("Enter string:");
Scanner scan = new Scanner(System.in);
String s = scan.nextLine();
System.out.println("Reversed String: " + U10_L2_Activity_One.reverseString(s));
}
}
Computers and Technology
1 answer:
Nady [450]2 years ago
7 0

Answer:

Explanation:

The following modified code correctly uses recurssion to reverse the string that was passed as a parameter to the reverseString method. A test output using the runner class can be seen in the attached image below.

import java.util.Scanner;

class U10_L2_Activity_One {

   public static String reverseString(String str) {

       if (str.isEmpty()) {

           return str;

       }

       return reverseString(str.substring(1)) + str.charAt(0);

   }

}

class runner_U10_L2_Activity_One

{

   public static void main(String[] args)

   {

       System.out.println("Enter string:");

       Scanner scan = new Scanner(System.in);

       String s = scan.nextLine();

       System.out.println("Reversed String: " + U10_L2_Activity_One.reverseString(s));

   }

}

You might be interested in
your manager asks you to set up a secure network connection at a remote site to move over some backups which protocol would you
nlexa [21]

The protocol that should be used for establishing a secure network connection is SSH.  

The following information is to be considered:  

  • SFTP is secure also it is a protocol for file transferring that applied SSH.
  • IP, FTP, and DHCP should not be for safety purposes as they are not secure.
  • SSH is a secured connection for the remote sites so here the SSH protocol should be used.

Therefore we can conclude that The protocol that should be used for establishing a secure network connection is SSH.

4 0
2 years ago
21. What is the set of events that occurs between the moment you turn
Fantom [35]

Answer:

The boot loader is pulled into memory and started. The boot loader's job is to start the real operating system. POST (Power On Self Test) The Power On Self Test happens each time you turn your computer on. ... Your computer does so much when its turned on this isn't all that occurs but is a summirazed version of what happens

7 0
2 years ago
How can you skillfully use the internet for research
elena-s [515]

By looking up your research on websites that have (.org) or wikipedia for answers u might have to find information

6 0
3 years ago
Which option is the easiest way to configure macros in Access 2016?
zhuklara [117]
Number 2
Have a nice day
6 0
3 years ago
You would like to find the average of cells C2, C3, and C4. What should the formula look like? = C2+C3+C4*3 =C2+C3+C4/3 =(C2+C3+
Marizza181 [45]

Answer:

c3 and c4 and c2 are different and same

Explanation:

average cells are ptoboxide

3 0
3 years ago
Read 2 more answers
Other questions:
  • You would like to set up an online meeting to communicate with colleagues on a group project. Which of these tools should you su
    9·1 answer
  • Jim wants to develop an app for a specific purpose that would run even when his computer is not connected to the Internet. What
    11·1 answer
  • You can apply several different worksheet themes from which tab?
    11·2 answers
  • Of the two basic methods of data entry, keyboards use keystrokes to enter data and instructions; what is the nonkeyboard method
    7·1 answer
  • W-11/6=4<br><img src="https://tex.z-dn.net/?f=%20%20%5Cfrac%7Bx%20-%2011%20%7D%7B%206%7D%20%20%3D%204" id="TexFormula1" title="
    14·1 answer
  • The term computer ________ is used to describe someone who is familiar enough with computers to understand their capabilities an
    12·1 answer
  • Which leader of the Jamestown colony am I?
    15·2 answers
  • Assume that strikeCounter has already been declared to be a "pointer to int". Assume further that strikeCounter has been initial
    5·1 answer
  • wants to redesign the user interface. The customer service agents use ________ to enter explicit statement to invoke operations
    11·1 answer
  • Write a Python program (rainfall.py) to collect data and calculate the average rainfall over a period of years. The program shou
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!