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]
2 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]2 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]2 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
Company A is setting up a network of mostly Windows machines. Which networking file system protocol would you recommend for maxi
maxonik [38]

Answer:

For maximum interoperability, NFSv4 is recommended.

Explanation:

When setting up a network of mostly windows machines, it is better to use NFSv4 because it includes performance improvements, mandates strong security, and a stateful protocol.

4 0
3 years ago
How are Action Buttons different than hyperlinks?
ipn [44]

Actions buttons are different than hyperlinks in many ways.

2)They are predefined shapes.

<u>Explanation:</u>

Action buttons are predefined shapes in the PowerPoint and can be used for moving between the slides of the presentation and for referring to the hyperlinks as well.

Action buttons have a predefined shape and that shape can be used to set the functionality of that particular button as a convention. Action buttons make up a strong presentation.

Action buttons can be invoked by clicking on them or just hovering over them and various sound effects can also be added on both the events to make the presentation more engaging and attractive.

8 0
2 years ago
What stage of software development incorporates planning to help make changes in the project plan based of reviews
larisa86 [58]

Answer:

A

Explanation:

8 0
2 years ago
_____ are unique identifiers of computer or network addresses on the internet.
Gnesinka [82]
The answer is IP address.
5 0
2 years ago
Read 2 more answers
ossless compression tools generally use either Huffman coding or Lempel-Ziv-Welch (LZW) coding. Discuss the advantages and disad
anygoal [31]

Answer:

It we were asked to develop a new data compression tool, it is recommended to use Huffman coding since it is easy to implement and it is widely used.

Explanation:

The pros and the cons of Huffman coding

Huffman coding is one of the most simple compressing encoding schemes and can be implemented easily and efficiently. It also has the advantage of not being patented like other methods (e.g. arithmetic codingfor example) which however are superior to Huffman coding in terms of resulting code length.

One thing not mentioned so far shall not be kept secret however: to decode our 96 bit of “brief wit” the potential receiver of the bit sequence does need the codes for all letters! In fact he doesn’t even know which letters are encoded at all! Adding this information, which is also called the “Huffman table” might use up more space than the original uncompressed sentence!

However: for longer texts the savings outweigh the added Huffman table length. One can also agree on a Huffman table to use that isn’t optimized for the exact text to be transmitted but is good in general. In the English language for example the letters “e” and “t” occur most often while “q” and “z” make up the least part of an average text and one can agree on one Huffman table to use that on average produces a good (=short) result. Once agreed upon it doesn’t have to be transmitted with every encoded text again.

One last thing to remember is that Huffman coding is not restricted to letters and text: it can be used for just any symbols, numbers or “abstract things” that can be assigned a bit sequence to. As such Huffman coding plays an important role in other compression algorithms like JPG compression for photos and MP3 for audio files.

The pros and the cons of Lempel-Ziv-Welch

The size of files usually increases to a great extent when it includes lots of repetitive data or monochrome images. LZW compression is the best technique for reducing the size of files containing more repetitive data. LZW compression is fast and simple to apply. Since this is a lossless compression technique, none of the contents in the file are lost during or after compression. The decompression algorithm always follows the compression algorithm. LZW algorithm is efficient because it does not need to pass the string table to the decompression code. The table can be recreated as it was during compression, using the input stream as data. This avoids insertion of large string translation table with the compression data.

3 0
3 years ago
Other questions:
  • You should use _____ software for writing a letter.
    10·1 answer
  • What type of elements are bridges exposed to yearly
    13·2 answers
  • You often insert your company's logo into documents you create. One way to make it easier for you to quickly insert it is to sav
    10·1 answer
  • There are several factors that can substantially affect the consumer search process. Match the factor with an example of how the
    5·1 answer
  • During the ________ phase of the systems development life cycle process, developers construct, install, and test the components
    13·1 answer
  • DNA is the fundamental encoding of the instructions that govern the operation of living cells and, by extension, biological orga
    5·1 answer
  • How can you have a safe browser experience
    9·1 answer
  • can you give me a tip to fix my SIM card becuaus when i put it on my phone it has no signal , can anyone fix this , thank you.​
    9·2 answers
  • It is possible to limit the search results to a range of publication dates.
    13·1 answer
  • Write a program that produces the following output: CCCCCCCCC ++ ++ CC ++ ++ CC ++++++++++++++ +++++++++++++++ CC ++++++++++++++
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!