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
Joseph wants to take out the color of the background wall from an image what can Joseph do to achieve this​
snow_lady [41]

Answer:

Go to remove a background website

Explanation:

6 0
2 years ago
Read 2 more answers
Which characteristic of Cloud computing allows data centers to better manage hard drive failures and allocate computing resource
MrMuchimi

Answer:

When working with cloud computing, drive failures and need for usage and data is easily identifiable, so in short term, all of the things that show the user/s what needs to be done is the characteristic.

Explanation:

5 0
2 years ago
Solve for x<br><br>4d+3/8=-2​
Alexxx [7]

Answer:

-19/32

Explanation:

(If I assume d to be x)

4x+3/8=-2

or,4x=-2-3/8=-19/8

or,x=(-19/8)*(1/4)=-19/32

5 0
3 years ago
QUESTION 6 Which of the following is a class A IPv4 address? a. 118.20.210.254 b. 183.16.17.30 c. 215.16.17.30 d. 255.255.0.0
shepuryov [24]

Answer:

a. 118.20.210.254

Explanation:

Here are the few characteristics of Class A:

First bit of the first octet of class A is 0.

This class has 8 bits for network and 24 bits for hosts.

The default sub-net mask for class A IP address is 255.0.0.0

Lets see if the first bit of first octet of 118.20.210.254 address is 0.

118 in binary (8 bits) can be represented as : 1110110

To complete 8 bits add a 0 to the left.

01110110

First bit of the first octet of class A is 0 So this is class A address.

For option b the first octet is : 183 in the form of bits = 10110111 So it is not class A address

For option c the first octet is 215 in the form of bits = 11010111 So it is not class A address

For option d the first octet is 255 in the form of bits = 11111111. The first bit of first octet is not 0 so it is also not class A address.

3 0
3 years ago
47. Which of these examples demonstrates good netiquette?
Masteriza [31]

Answer:

typing it, on a video detailing how boring and poorly made it is

Explanation:

this is an example of good netiquette because they are criticizing the video game and what good netiquette is is making a comment relevant to the original message. the original message being the video game

3 0
3 years ago
Other questions:
  • You just read an msds for acetic acid. based on what you read, what type of information is included in an msds sheet? record you
    7·1 answer
  • What is the most efficient way to include a space after each paragraph?
    13·2 answers
  • A .jpg file is an example of which of the following file types
    15·2 answers
  • Write a program that inputs a time from the console. The time should be in the format "HH:MM AM" or "HH:MM PM". Hours may be one
    6·1 answer
  • My friend Leo wants to have an emergency plan for his final exams on University of Southern Algorithmville. He has N subjects to
    6·1 answer
  • Match each role to the corresponding web development task.
    14·1 answer
  • PLEASE HELP I WILL GIVE BRAINLIEST!!!!
    7·2 answers
  • If 209g of ethanol are used up in a combustion process, calculator the volume of oxygen used for the combustion at stp​
    5·1 answer
  • Write a python program that will read a number (num) and display all the numbers divisible by 3 or 5
    15·1 answer
  • What is used for risk response control?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!