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
OlgaM077 [116]
3 years ago
6

Write a recursive method public static String reverse(String str) that computes the reverse of a string. For example, reverse("f

low") should return "wolf". Hint: Reverse the substring starting at the second character, then add the first character at the end. For example, to reverse "flow", first reverse "low" to "wol", then add the "f" at the end.
Computers and Technology
1 answer:
Aneli [31]3 years ago
5 0

Answer:

Explanation:

StringRecursiveReversal.java

public class StringRecursiveReversal {

   static String reverse1 = "";

   public static String reverse(String str){

       if(str.length() == 1){

           return str;

       } else {

           reverse1 += str.charAt(str.length()-1)

                   +reverse(str.substring(0,str.length()-1));

           return reverse1;

     }

   }

   public static void main(String a[]){

       StringRecursiveReversal srr = new StringRecursiveReversal();

       System.out.println("Result: "+srr.reverse("flow"));

   }

}

Output :

Result: wolf

You might be interested in
File Sales.java contains a Java program that prompts for and reads in the sales for each of 5 salespeople in a company. It then
myrzilka [38]

Answer:

import java.util.Scanner;

public class Sales

{

public static void main(String[] args) {

   

    int sum;

    Scanner input = new Scanner(System.in);

   

    System.out.print("Enter number of salespeople: ");

    int salespeople = input.nextInt();

    int[] sales = new int[salespeople];

       

    for (int i=0; i<sales.length; i++)

    {

     System.out.print("Enter sales for salesperson " + (i+1) + ": ");

     sales[i] = input.nextInt();

    }

    System.out.println("\nSalesperson   Sales");

    System.out.println("--------------------");

    sum = 0;

       int maxSale = sales[0];

       int minSale  = sales[0];

       int minId=1;

       int maxId=1;

    for (int i=0; i<sales.length; i++)

    {

               System.out.println("     " + (i+1) + "         " + sales[i]);

 sum += sales[i];

  if(maxSale < sales[i])

           {

               maxSale = sales[i];

               maxId = i+1;

           }

           if(minSale > sales[i])

           {

               minSale = sales[i];

               minId = i+1;

           }

   }

System.out.println("Total sales: " + sum);

       System.out.println("The average sale is: " + sum / salespeople );

       System.out.println("Salesperson "+ maxId + " had the highest sale with "+ maxSale + ".");

       System.out.println("Salesperson "+ minId + " had the lowest sale with "+ minSale + ".");

       

       int amount = 0;

       int counter = 0;

       System.out.print("Enter an amount: ");

       amount = input.nextInt();

       for (int i=0; i<sales.length; i++)

    {

     if(sales[i] > amount) {

         counter++;

         System.out.println("Salesperson "+ (i+1) + " exceeded given amount. (Number of sales: " + sales[i] +")");

     }

    }

       System.out.println("Number of salespeople exceeded given amount is: "+ counter);

}

}

Explanation:

- Ask the user for the number of salesperson

- According to entered number, create an array called sales to hold sale number for each person

- In the first for loop, assign the given sales numbers

-  In the second for loop, print all the sales people with sales, calculate the total sales. Also, find the minimum and maximum sales numbers with associated individuals.

- Print total, average, highest, and lowest sales.

- Ask user enter an amount

- In the third for loop, find the sales people who exceeded this amount.

- Print number of sales people who exceeded the amount.

8 0
3 years ago
6.An organization wants to implement a remote dial-in server to ensure that personnel can connect to the organization's network
Sauron [17]

Answer:

Challenge-Handshake Authentication Protocol (CHAP).

Explanation:

In Computer technology, authentication can be defined as the process of verifying the identity of an individual or electronic device. Authentication work based on the principle (framework) of matching an incoming request from a user or electronic device to a set of uniquely defined credentials.

Basically, authentication ensures a user is truly who he or she claims to be, as well as confirm that an electronic device is valid through the process of verification.

In this scenario, an organization wants to implement a remote dial-in server to ensure that personnel can connect to the organization's network from remote locations. The authentication protocol must include encryption to prevent hackers from accessing the network.

Hence, the protocol which should be used is Challenge-Handshake Authentication Protocol (CHAP).

A Challenge-Handshake Authentication Protocol (CHAP) can be defined as a standard network access control protocol in which a client program dials in to a network access server to receive a random value and identification number that can only be used once.

5 0
3 years ago
Whatis NOT a key factor while designing a website?
Vaselesa [24]

Answer: Complexity

Explanation: Web designing is referred as the designing of a web page for different purposes such as online business,etc. The most important factor is usability for the improvement in performance of any site and keeping it successful.

It should be user friendly so that interaction and understanding between user and web page can easy.Consistency is also a feature which ensure that web page opened in any browser should have similar quick working.

But there should be no complexity present in the web design which can cause misunderstand with the user and functioning.

7 0
3 years ago
What does a file extension tell you?
kiruha [24]

A. because everyone basically has seen it..

3 0
3 years ago
Which of the following statements best represents the impact vaudeville had on the film industry? Early silent films were more r
maria [59]

Answer:

Answer is B: Early silent film producers used many of the same acting techniques popularized in vaudeville performances, even using popular vaudeville stars as actors in their productions.

Explanation:

7 0
2 years ago
Other questions:
  • Jeff wants to print quickly so he presses the Ctrl and the P. Jeff used a _____. macro invoice template shortcut
    15·1 answer
  • How do u determine the voltage across diode
    15·1 answer
  • Explain Cascading Style Sheets and what they do. Describe their primary function, two effects that this function has on programm
    11·1 answer
  • Template files can contain the following items: text, tables, images and lists.
    10·1 answer
  • You are reviewing the style sheet code written by a colleague and notice several rules that are enclosed between the /* and */ c
    12·1 answer
  • How many bits would be in the memory of a computer with 4kb memory?
    8·1 answer
  • Illusions in physcology​
    14·1 answer
  • Were does igneous rocks cool?
    9·1 answer
  • Select the best answer from the drop-down menu.
    14·2 answers
  • Consider the following implementation of a search method:
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!