StringReverser
Given the following code that creates a Scanner and gets a String from the user, finish the code so that the program will:
Output the provided String, input, backwards
Note that the answer should be one phrase - the reverse of input.
The use of an additional method is optional.
SAMPLE OUTPUT
======================
Enter a word or phrase:
this is a test
REVERSED:
tset a si siht

Respuesta :

Answer:

Explanation:

The following code is written in Java, it uses the scanner import to take in a string from the user. Then it uses the string builder import to use the input string and reverse it. Finally outputting the reversed string. The output can be seen in the attached picture below.

import java.util.Scanner;

class Brainly

{

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter a string: ");

       String answer = in.nextLine();

       StringBuilder sb=new StringBuilder(answer);

       sb.reverse();

       System.out.println("Reversed: \n" + sb.toString());

   }

}

Ver imagen sandlee09