Question: Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending
Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending when the user enters "Done", "done", or "d" for the line of text. Ex: If the input is: Hello there Hey done the output is: ereht olleH yeH import java.util.Scanner; public class LabProgram { public static void main(String[] args) { while (true) { } String line = scan.nextLine(); if (line.equalsignore Case("Done") Il line.equalsignoreCase("d")) { break; } StringBuilder sb = new StringBuilder (line); System.out.println(sb.reverse().toString()); scan.close();
Step by Step Solution
There are 3 Steps involved in it
OUTPUT This program uses a Scanner to read the users input It then checks if the input is Done ... View full answer
Get step-by-step solutions from verified subject matter experts
