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
How do you make someone brainlest
HACTEHA [7]

Answer:

When you ask a question, people have to option to responds and when you have two different users respond on your question, there is the option to give one of them the Brainliest award for the best answer.

Hope this Helps!

4 0
4 years ago
Read 2 more answers
What does this symbol “=“ mean
ikadub [295]

it means equals thanks for the free points

8 0
3 years ago
Read 2 more answers
Define a data type for representing complex numbers. (A complex number consists of 'real' and 'imaginary' parts. The real and im
qwelly [4]

Answer:

A complex data type can be created by the use of class or structures.

#include <iostream>

using namespace std;

class complex{//creating a class complex to store a complex value.

public://defining all the values public.

int real;

int img;

complex(int real,int img)//parameterized constructor.

{

    this->real=real;

    this->img=img;

}

};

int main() {

   complex n1(1,2);//n1 is a complex number with real part 1 and imaginary part 2.

   cout<<n1.real<<" i"<<n1.img<<endl;

return 0;

}

Output

1 i2

Explanation:

I have created a class complex to store complex number with two integer parts real and imaginary.You can also declare them float if you wan to store decimal values and after that i have created a parameterized constructor with real and imaginary values.So we can assign the values at the time of declaration of the object of class complex.

5 0
3 years ago
Imagine you are part of a school newspaper or school yearbook club. What application software would you need in order to produce
djyliett [7]

Answer:

MS-Word

Explanation:

MS-Word is the application software that is used for document creation or for word processing. It is the widely used software for content writing purposes and processing of words. It is available by Microsoft.

MS- Word is very useful when writing any paragraph or any article for a book or for any newspaper. We can modify or edit our content in the application software. It is basically a word processor that was developed by Microsoft company in the year 1983.

In the context, MS-Word is the best application software that is used to produced the work for the school newspaper or for the school yearbook club.

7 0
3 years ago
You were recently hired by a small start-up company. The company is in a small office and has several remote employees.
Romashka [77]

Answer:

D) IaaS

Explanation:

In this scenario, the best cloud service model would be IaaS. This stands for Infrastructure as a service (IaaS) and basically provides all the physical infrastructure that a company needs virtually. The company itself purchases a piece of software that allows them to remotely use all of the infrastructure provided by the service. Meaning they have access to computing power, data centers space, servers, networking, etc. without actually purchasing any of the physical hardware. This would solve all of "your" business needs as asked by the company.

6 0
3 years ago
Other questions:
  • Alex has started a Google Search campaign designed to promote his online motorcycle accessories store. His store focuses on cust
    6·1 answer
  • After execution of the code fragment
    8·1 answer
  • A ________ describes the data and relationships that will be stored in a database.
    10·1 answer
  • How to help it automation with python professional certificate?
    10·1 answer
  • Which of the following is considered proper typing technique?
    15·1 answer
  • National Computer Corporation (NCC) employs Cynthia as an agent. NCC gives her an exclusive territory in which to sell NCC produ
    6·1 answer
  • Select three advantages of cloud computing.
    12·1 answer
  • I'll mark you the brainlest please help
    14·2 answers
  • You need to know more than just facts in order to use critical thinking skills.
    5·1 answer
  • How many parts make up a web address? One To Three​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!