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
Harrizon [31]
3 years ago
5

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.
Ex: If the input is:

Hello there
Hey
quit
then the output is:

ereht olleH
yeH

I can't figure out how to make this code. If anyone could help I would appreciate it.
Computers and Technology
2 answers:
Nana76 [90]3 years ago
7 0

<u>Answer:</u>

<em>using System; </em>

<em>public class Program </em>

<em>{ </em>

<em> public static void Main() </em>

<em> { </em>

<em> String input ; </em>

<em> while(true) </em>

<em> { </em>

<em>  input = Console.ReadLine(); </em>

<em>  if(input.Equals(""quit"")) </em>

<em>  break; </em>

<em>  Reverse_String(input); </em>

<em> } </em>

<em> return; </em>

<em> } </em>

<em>static void Reverse_String(string input_text) </em>

<em>{ </em>

<em>    char[] text = input_text.ToCharArray(); </em>

<em>    Array.Reverse(text); </em>

<em>    Console.WriteLine(text); </em>

<em>} </em>

<u>Explanation:</u>

<em>In the above program a separate function is written to reverse the string.</em>

This method takes the string as an argument and place it in a array and then use the built-in function reverse and print the reversed string in the console.

<em>In the main(), the input is obtained from the console and it is passed to the reversestring(). </em>

kkurt [141]3 years ago
5 0

Answer:

while True:

       values = str(input())

       if values == 'quit' or values == 'Quit' or values == 'q':

              break

       print(values[::-1])

Explanation:

Firstly, save the code on a folder and save it with any name but it must end with .py . Example data.py, save.py, reverse.py etc. Afterward, you run the code on the python shell . On the shell type  "python saved filename(save.py or data.py, reverse.py)"

I used python to solve the problem. Normally, if one wants to iterate or loop through a particular function or code you  use a loop. In this case i used a while loop.

Using while True , the values will always loop since True is always True.

values = str(input()) , This code make sure the input is always a string, since we want only text.

if values == 'quit' or values == 'Quit' or values == 'q':  , This code means the values should quit or stop working if the user input any of the text "quit" or "Quit" or "q".

print(values[::-1]) ,  This code means the input text should be reversed. example joy will be yoj

Generally, the code will always loop and print the reverse of the text unless it encounter any input value like "quit" or "Quit" or "q"

You might be interested in
Which statement reflects inherent bias in reading and learning about our world?
love history [14]
I had to look for the options and here is my answer:

The statement that best illustrates what inherent bias is at is is used in reading and learning about the world is this: "<span>Historians are interpreting the past." Definitely, historians do not interpret the past, but rather their field focuses on gaining facts and information related the past.</span>
8 0
3 years ago
___ is a career discipline focusing on helping companies use computer technology effectively.
pickupchik [31]

Answer:

A (information technology)

Explanation:

4 0
2 years ago
Hi, please help me, solution.​
loris [4]

Answer:

error: incompatible types

Explanation:

Given

The attached code

Required

The output

Variable "a" is declared as float

While p is declared as a pointer to an integer variable

An error of incompatible types will be returned on line 3, <em>int *p = a;</em>

Because the variables are not the same.

To assign a to p*, we have to use type casting.

Hence, (b) is correct

5 0
3 years ago
A(n) _____ is a flexible tool used to analyze data using reports that do not have a predetermined format.
Mandarinka [93]

Answer:

decision support system

Explanation:

4 0
2 years ago
What might be some examples of Digital Citizenship Behavior?
likoan [24]

Answer:

Being nice to others and being respectful. Acting appropriately and with respect for you and others.

Explanation:

☆Hope this helps!☆

6 0
3 years ago
Other questions:
  • Information is a valuable asset and not everyone in the world can be trusted with it. Therefore, we need to protect our valuable
    10·1 answer
  • Write a function called median, that takes as parameter a full, sorted array of doubles and returns the median of the list. For
    15·1 answer
  • What step can Miguel take to solve his dilemma? Miguel is working on a project that requires him to switch back and forth freque
    12·2 answers
  • The counter in a for or while loop can have an explicit increment: for i=m:k:n. This advances the counter i by increment k each
    15·1 answer
  • Over the past few years a very definite need has arisen in the electrical trades for:
    15·1 answer
  • In an income statement subtracting the cost of goods sold from the net sales provides the?
    11·1 answer
  • A person's oral communication skills can give either a positive or negative first impression.
    12·1 answer
  • Which of these are tools used to diagnose and test code? Check all of the boxes that apply.
    9·1 answer
  • Which of the following expressions in Java is equal to 4?
    11·1 answer
  • Write code that outputs variable numCats. End with a newline.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!