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
Can y’all help me with these questions ?
andriy [413]
45. Nic card
46. Word processing
7 0
3 years ago
Integration Management, one of the 10 PMBOK Guide Knowledge Areas, represents the processes and activities to identify, define,
-Dominant- [34]

Answer:

The answer is "True".

Explanation:

Integration control is a system selection, which is important to ensure the proper coordination of the different components of the programs. Analogies between conflicting goals and solutions must be made to meet or surpass the needs and wishes of participant groups. This mechanisms use events for identifying, defining, combining, unifying and coordinating software development procedures and events, that's why the given statement is true.

6 0
3 years ago
How many people watch Anime in the world?
iren [92.7K]
3 to 4 billion people.

7 0
3 years ago
Read 2 more answers
What's the smallest part of a computer
Murljashka [212]

Answer:

A byte

Explanation:

I just had that question on my quiz

7 0
3 years ago
Read 2 more answers
Which of the following are benefits of designing a scalable system? choose 3 options.
ollegr [7]
I asked my brother since he’s kinda of tech geek and he said

The 1st, 3rd, and 5th answers are correct

Hope this helps and I hope my brother is not wrong.
7 0
3 years ago
Other questions:
  • In which area of engineering does material selection play a vital role a design optimization b forensic engineering c mechanical
    6·1 answer
  • Hackers who gain control over several computers can organize them into a client-server network known as a(n) __________ . This n
    7·1 answer
  • Vicky is investigating multiple hacking attempts on her cloud-based e-commerce web servers. She wants to add a front-end securit
    5·1 answer
  • Similarities between inline css and internal css​
    6·1 answer
  • Does nature behave the exact same way as fractals?
    15·1 answer
  • HEPME <br> ZOOM<br> IN <br> STOP<br> GIVIJG<br> ME <br> LINKS <br> !!
    9·1 answer
  • Which TWO of the following are input devices that are parts of a laptop computer?
    9·2 answers
  • (1) Prompt the user to enter two words and a number, storing each into separate variables. Then, output those three values on a
    10·1 answer
  • Which statement correctly describes the difference between an IP address and a MAC address for a
    14·1 answer
  • When a ____________ file is opened, it appears full-screen, in slideshow mode, rather than in edit mode.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!