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 part of a computer is responsible for executing the software programs?
mamaluj [8]

Answer:

c. CPU

Explanation:

7 0
3 years ago
The function of an audio mixer is to _____. layer audio tracks at their ideal volume combine, control, and route audio signals f
larisa [96]

Answer: combine, control, and route audio signals from inputs to outputs

Explanation:

A audio mixer is refered to as the sound mixer or the mixing console and it's an electronic device that's used for mixing, and combining several audio signals and sounds.

The input to the console is the microphone. The audio mixer can also be used in controlling digital or analog signals. These are then summed up in producing output signals.

Therefore, the function of the audio mixer is to combine, control, and route audio signals from inputs to outputs.

7 0
3 years ago
You decide to use a packet sniffer to identify the type of traffic sent to a router. You run the packet sniffing software on a d
ycow [4]

Answer:

Promiscuous mode

Explanation:

You decide to use a packet sniffer to identify the type of traffic sent to a router. You run the packet sniffing software on a device connected to the same hub that is connected to the router. When you run the software, you only see frames addresse…

✓ Promiscuous mode

7 0
2 years ago
Which term is used to mean the methods of a predator uses to befriend youth online?
sammy [17]
Pretty sure its called the grooming process

6 0
3 years ago
Read 2 more answers
One shortcoming of rapid application development (RAD) is _____.
VladimirAG [237]
One shortcoming of rapid application development (RAD) is a narrow focus, which might limit future development.
8 0
3 years ago
Other questions:
  • What is the difference between HTML and CSS? * 1. CSS is a markup language unlike HTML. 2. HTML is a backend technology and CSS
    12·2 answers
  • Which of the following is NOT a destination?
    12·2 answers
  • PLEASE HELP !!!! WILL UPVOTE
    5·2 answers
  • A detective agency is looking to bust an arms sale. According to available intelligence, the sale is likely to happen in one of
    11·1 answer
  • During which part of geologic time did photosynthesis evolve?
    15·2 answers
  • Which of the following is true of Chinese Opera: Two opera centers emerged Beijing and Yangzhou 300-400 forms of opera arose in
    10·1 answer
  • What is a multipurpose network device?
    10·1 answer
  • Lol fortnite really going UwU and anime
    12·2 answers
  • 2 4.1.2 Quiz: Information Systems and Business Planning
    11·1 answer
  • What is the difference between turn-based game mode and point-based game mode?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!