Ask Question

4.24 LAB: Print string in reverse 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:

+2
Answers (1)
  1. 8 January, 00:13
    0
    See explaination

    Explanation:

    import java. util. Scanner;

    public class LabProgram {

    public static void main (String[] args) {

    Scanner in = new Scanner (System. in);

    String line;

    while (true) {

    line = in. nextLine ();

    if (line. equals ("quit") || line. equals ("Quit") || line. equals ("q")) break;

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

    System. out. print (line. charAt (line. length () - i - 1));

    }

    System. out. println ();

    }

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “4.24 LAB: Print string in reverse Write a program that takes in a line of text as input, and outputs that line of text in reverse. The ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers