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 "Quit", "quit", or "q" for the line of text.
Ex: If the input is:
Hello there
Hey
quit
the output is:
ereht olleH
yeH
IN JAVA
import java.util.Scanner; public class LabProgram { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String s = scan.nextLine(); while (!(s.equals("Quit")||s.equals("quit")||s.equals("q"))){ for(int i = s.length()-1;i>=0;i--){ System.out.print(s.charAt(i)); } System.out.println(); s = scan.nextLine(); } } }
Get Answers For Free
Most questions answered within 1 hours.