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
Rom4ik [11]
4 years ago
9

Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending whe

n the user enters "Quit", "quit", or "q" for the line of text. in java.
Computers and Technology
1 answer:
OLEGan [10]4 years ago
6 0

Answer:

The solution code is as below:

  1.        Scanner input = new Scanner(System.in);
  2.        System.out.print("Input a string: ");
  3.        String inStr = input.nextLine();
  4.        int strLen = inStr.length();
  5.        while(inStr.equals("Quit") != true && inStr.equals("quit") !=true && inStr.equals("q") != true){
  6.            for(int i= 0; i < strLen; i++){
  7.                System.out.print(inStr.charAt(strLen - 1 - i));
  8.            }
  9.            System.out.println();
  10.            System.out.print("Input a string: ");
  11.            inStr = input.nextLine();
  12.            strLen = inStr.length();

Explanation:

Firstly, we create a Scanner object,<em> input</em> (Line 1).

Next, we use the Scanner object nextLine() method to get a text input from user (Line 3).

We create a while loop and set the condition so long as the input text is not equal to "Quit", "quit" or "q" (Line 6), the program should proceed to print the input text in reverse (Line 8-10). To print the text in reverse, we can apply the expression<em> length of string - 1 - current index</em>.  This will ensure the individual letter is read from the last and print the text in reverse.

Next, prompt the user to input a new text (Line 13-14) and repeat the same process of printing text in reverse so long as the current input text is not "Quit", "quit" or "q".

You might be interested in
What port in your computer will you use to plug in your camera?
V125BC [204]
I think it would be fire wire
8 0
3 years ago
Read 2 more answers
The HTTP protocol operates at which layer?
Ludmilka [50]

Answer:

transport

Explanation:

taking you to what ever website you want

5 0
3 years ago
Whate is function of northe bridge<br>​
Scorpion4ik [409]

Answer:

After this I'm officially a virtuoso

Explanation:

Sorry bout the spelling

3 0
3 years ago
Please help me. Adnan also wants to add a photograph of a bridge. It is on another PowerPoint presentation that is open in a dif
Nana76 [90]
C. screen clipping feature
7 0
3 years ago
How can a search be narrowed to only search a particular website????
vesna_86 [32]

Answer:

There are a variety of ways to narrow down your search results in a library database. The two most direct ways are to focus your search with more specific keywords and/or to limit by various criteria before or after searching. The more specific you are with your search terms, the more relevant your results will be

Hope it helped!!!

4 0
3 years ago
Other questions:
  • Write the interface (.h file) of a class ContestResult containing: An data member winner of type string, initialized to the empt
    14·1 answer
  • Which social networking function came first?
    9·2 answers
  • What do i study to become a network engineer?
    11·1 answer
  • Please help quickly!!! which of the following is not a peripheral?
    8·2 answers
  • What is the output?
    13·1 answer
  • Gabriel's sister called him about a message that suddenly appeared on her screen that says her software license has expired and
    11·1 answer
  • C++ Write a program that initially asks a user to enter two positive integer numbers a and b. If either a or are zero or negativ
    9·2 answers
  • NAT addresses concerns over the dwindling IPv4 address space by ___________________. 1 point allowing networks to use fewer IP a
    15·1 answer
  • A network administrator wants to authenticate server machines using Transport Layer Security (TLS). What can the administrator i
    15·1 answer
  • LAB: Phone number breakdown Given a long long integer representing a 10-digit phone number, output the area code, prefix, and li
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!