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
Why do businesses often provide a logo on their web pages?
Nitella [24]
<span>B. They provide viewers with a consistent visual reminder of their company.

This is a prevalent example of branding.</span>
7 0
3 years ago
Cell division is called:
Blizzard [7]

Answer:

Mitosis

Explanation:

6 0
2 years ago
Type which type of interference we will install after installing operating system​
pentagon [3]

Answer:

There are different kinds of operating systems: such as Windows, Linux and Mac OS

There are also different versions of these operating systems, e.g. Windows 7, 8 and 10

Operating systems can be used with different user interfaces (UI): text user interfaces (TUI) and graphical user interfaces (GUI) as examples

Graphical user interfaces have many similarities in different operating systems: such as the start menu, desktop etc.

When you can recognize the typical parts of each operating system’s user interface, you will mostly be able to use both Windows and Linux as well as e.g. Mac OS.

THE ROLE OF OPERATING SYSTEM IN THE COMPUTER

An operating system (OS) is a set of programs which ensures the interoperability of the hardware and software in your computer. The operating system enables, among other things,

the identification and activation of devices connected to the computer,

the installation and use of programs, and

the handling of files.

8 0
3 years ago
TVBCA has just occupied an old historic building in downtown Pittsburgh in which 15 employees will work.
7nadin3 [17]

Answer:

A. The proposed solution delivers the required result and both optional desired results.

Explanation:

The IEEE 802.11a is the standard code of the wireless communication technology known as WIFI, it is wireless as it requires no cable to connect to a network device. The data transmission rate of the IEEE 802.11a is 1.5 - 54Mbps (mega bit per second). So, the employees in the TVBCA building can wireless connect to the network, which allows them to be mobile and they can also send large CAD files among themselves.

6 0
3 years ago
Don't click on this I am testing
Andrew [12]

Don't click on this I am testing... I want the points so.

3 0
3 years ago
Read 2 more answers
Other questions:
  • Being tired has very similar effects on the body as what
    7·1 answer
  • If variable x has value 2 and y has value 2, what is the value of the following Jack expression?
    9·1 answer
  • PLEASEEE HELPPPP me
    13·1 answer
  • The Occupational Outlook Handbook is published by the Bureau of Labor Statistics.
    14·1 answer
  • the easiest and cheapest time to alter the information system is in the ________ phase of the sdlc. a. requirements analysis b.
    8·1 answer
  • A major difference between digital librarians and traditional librarians is that traditional librarians rarely work with people.
    15·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
    5·1 answer
  • If Laura wanted to solve a problem using recursion where the last statement executed is the call to the same method, what type o
    8·1 answer
  • Which way do you swipe in ios to get to the control center
    15·1 answer
  • If you do a Find and Replace for a term, where will Word begin looking for the term?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!