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]
3 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]3 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
Which element can be changed using the Print pane? Check all that apply
asambeis [7]

Answer:B C D E

Explanation:

EDGE 2021

3 0
3 years ago
You are the network administrator for Slimjim, a peripheral device company. The network uses Linux, and you need information on
oksano4ka [1.4K]

Step 1 of 4

What command did you use to accomplish this task?

First of all, let us ask ourselves what manual pages or man pages are. Manual pages in Unix/Linux are sometimes referred to as an online form of software documentation. They are a set of pages that try to explain and expound every command available on your system. Further, these pages explain to you the specifics of what each command does and how to run them. And in this case, we can use two commands to search for all the commands that have the word "copy" in their name or description. The commands are “man –k copy” or “apropos copy”

Step 2 of 4

Are there any commands in this list that only a root user can execute? How are they indicated?

Yes. There are several commands in this list that only a root user can execute. If you would want to find out what these commands are, the best way to do that is to look at those manual pages that are indicated by the manual page section number. If it has a number 8, then a root user can execute this command

Let’s compare the cp command and the cpio command

If you do an apropos or a man page on the commands above, you will spot a few differences. The cp command is used to copy files and directories from source to target location while the cpio command copies files to and from archives. The available options are –a –b –d –f –i –l –L –p and several others. On the other hand, the available options for cpio are –0 –a –A –b –B –C –c –d –E and more.

Access and read the manual pages on three other commands that interest you either by using the command name or searching for them by related keyword (try using apropos)

affcopy command

NAME

      affcopy - reorder and recompress AFF files

SYNOPSIS

      affcopy [options] file1 file

      affcopy [options] file1 file2 file3 ... dir

      affcopy [options] file1 file2 file3 ... dir1 dir2...

OPTIONS

General options:

             -d     Print debugging information as well.

             -h     Help, print this message.

             -L     Recompress pages (preen) with LZMA (smaller but slower).

             -m     Just copy the missing segments.

bcopy command

NAME

      bcopy - copy byte sequence

SYNOPSIS

      #include <strings.h>

      void bcopy(const void *src, void *dest, size_t n);

DESCRIPTION

      The bcopy() function copies n bytes from src to dest.  The result is correct, even when both areas overlap.

RETURN VALUE

      None.

cifssd command

NAME

      cifsdd - convert and copy a file over SMB

SYNOPSIS

      cifsdd [OPERAND]...

      cifsdd OPTION

DESCRIPTION

      This tool is part of the samba(7) suite.

      Copy a file, converting and formatting according to the operands.

      bs=BYTES

          read and write up to BYTES bytes at a time (default: 4096)

      ibs=BYTES

          read up to BYTES bytes at a time (default: 4096)

      obs=BYTES

          write BYTES bytes at a time (default: 4096)

6 0
3 years ago
Which boolean operator (and, not, or or) gives you the least results? *?
Readme [11.4K]
And, as it only includes results with just both terms. Or will give either and not will give everything but.
6 0
3 years ago
Dereck works for long hours on his computer. He frequently experiences physical strain by the end of the day because he does not
rjkz [21]
<span>keeping hands and wrists straight while typing</span>
3 0
3 years ago
Read 2 more answers
Bob's Assembly is a hardware manufacturer. It specializes in builders' hardware for doors, cabinets, windows, and bathrooms. Bob
Snezhnost [94]

Answer:

distinctive competence

Explanation:

The distinctive competence denotes the various characteristic of certain business on which behalf that business perform better than its competitors. And since the business succeeds in doing those things better than its competitors, that business gains a competitive advantage over its competitors. And here, Bob's assembly is a hardware manufacturer for the doors, cabinets, windows and the bathrooms. And his assembly products are more durable and economical than its competitor's products. And thus Bob has a competitive advantage over its competitors.

3 0
4 years ago
Other questions:
  • Ten 9600-bps lines are to be multiplexed using TDM. a. Ignoring overhead bits in the TDM frame, what is the total capacity requi
    6·1 answer
  • Find an element inside a div using javascript
    12·1 answer
  • Which payment type is best if you are trying to sick to a budget?
    15·1 answer
  • What element is used to configure a new paragraph?
    9·1 answer
  • Write a function "cashier" that receives an int "c" for the number of items bought. The function will ask the price and task rat
    11·1 answer
  • Write a SELECT statement that returns the same result set as this SELECT statement, but don’t use a join. Instead, use a subquer
    12·1 answer
  • This type of software works with end users, application software, and computer hardware to handle the majority of technical deta
    12·1 answer
  • Is Microsoft team voice lagging for people who use it I want to know I only want to know if you use it ok not if you don’t.
    6·1 answer
  • When an item is gray that means...
    15·2 answers
  • Inputs and outputs that allow a user to interact<br> with a piece of software
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!