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]
3 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]3 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
How to create drop down list in excel with multiple selections.
Art [367]

Answer: <em>Select the cell or cells you want the drop-down list to appear in.</em>

<em>Click on the Data tab on Excel's ribbon.</em>

<em>Click on the Data Validation button in the Data Tools group.</em>

<em>In the Data Validation dialog, in the Allow: list select List.</em>

<em>Click in the Source: box.</em>

<em />

<em></em>

<em />

8 0
3 years ago
Read 2 more answers
If your vehicle catches fire while you are driving, you should:
GalinKa [24]
Call emergency services and get as far away from it as possible
3 0
3 years ago
Read 2 more answers
Which software application offers a variety of templates for creating reports, flyers, and newsletters that you can access withi
denis-greek [22]
Either Word (Microsoft app) or Powerpoint (Microsoft app)
7 0
3 years ago
The first computer program was used to help the analytical engine calculate numbers. Who invented that program?
nikdorinn [45]

Answer:

Charles Babbage

Explanation:

Analytical engines were presumed to be the first general-purpose computer which was designed sometime in the 19th century by Charles Babbage -  a British mathematician and inventor. A series of punch cards was used by Charles Babbage in his design of the engine. These punch cards were used for various operations such as arithmetical operations, numerical constants and other operations such as load and store.

<em>Hope this works!</em>

8 0
3 years ago
One of your co-workers has been issued a new smart card because the old one has expired. The co-worker can connect to the comput
Lady_Fox [76]

Answer:

The answer is "The global Address List (GAL) is publishes in the new certificates".

Explanation:

Describe the GAL with relate to smart card:

  • The GAL is a part of the outlook, that allows the users to make a group of mutual contacts and resources specified for your G Suite domain and searchable directory.  
  • It provides the main mail app, that offers you to make global contacts, and also provides basic contact, with the use of business shares global addresses with others.  In this process, the co-worker can change their smart card.
5 0
3 years ago
Other questions:
  • Windows uses a graphical user interface (GUI), which means: a user can carry out commands by clicking, dragging, or otherwise ma
    6·1 answer
  • What daily life problems does the algorithm quicksort solve?
    14·1 answer
  • You can change the transparency of a picture used as a slide’s background with the ____.
    10·1 answer
  • For an machine using 2-dimensional even parity for error detection/correction, and the following received bytes, where is the er
    9·1 answer
  • The main purpose of a service panel in a house is to
    11·1 answer
  • " In which software generation did the distinction between systems programmers and other programmers first surface?"
    15·1 answer
  • Which of the following is not hardware? wireless network router X-box 360 game controller virus scanner flat-panel monitor
    5·2 answers
  • Which is not a factor that leads to technological advancement?
    8·1 answer
  • Which of the following substances increases in quantity during repititive muscle contraction during oxygen deficti ?
    11·1 answer
  • How to clear a function in functional component react.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!