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
Complete function PrintPopcornTime(), with int parameter bagOunces, and void return type. If bagOunces is less than 2, print "To
Ludmilka [50]

Answer:

#include <iostream>

using namespace std;

void PrintPopcornTime (int bagOunces){

   if (bagOunces < 2){

       cout << "Too small"<<endl;

   }

   else if (bagOunces > 10){

       cout << "Too large"<<endl;

   }

   else{

       cout << bagOunces*6 <<" seconds"<<endl;

   }

}

int main(){

   PrintPopcornTime(7);

   

   return 0;

}

Explanation:

Create a function called PrintPopcornTime that takes one parameter, bagOunces

Check the bagOunces using if-else structure. If it is smaller than 2, print "Too small". If it is greater than 10, print "Too large". Otherwise, calculate and print 6*bagOunces followed by " seconds".

Call the function in the main function with parameter 7. Since 7 is not smaller than 2 or not greater than 10, "42 seconds" will be printed.

4 0
2 years ago
Which sns gets its names from one of its unique features
Komok [63]

Answer:

no

Explanation:

3 0
3 years ago
Who is "TheBrain" He doesn't Give Answers, Or Questions, Keeps liking Profiles and.. Has Thousands of followers.. is he a Mod? ​
ss7ja [257]

Nope, he is a BOT not a MOD. He is made to run for this purpose only. He used to give answers in brainly.in but now he is used for deleting useless answers and questions, to welcome a new user and acts as a server bot.

You can also call "TheBrain" as AI

8 0
2 years ago
Who is known as the father of computer? ​
juin [17]

Answer:

Charles babbage ok my boy

8 0
3 years ago
Read 2 more answers
The add or remove columns button in the paragraph group on the ____ tab allows you to create multiple columns in a text box.
Allisa [31]
<span>By accessing the formatting tab on the program, individuals are able to create and distinguish columns within various text boxes that are created. This allows for the page to be adjusted as to the developers liking, and better portray the information.</span>
7 0
3 years ago
Other questions:
  • Windows enables each user to establish a ____, which identifies to windows the resources, such as apps and storage locations, a
    6·1 answer
  • 13. Microsoft PowerPoint is the best example of Multimedia Presentation
    14·2 answers
  • You would like to know how many cells contain data. Which function should you use? COUNT MIN SUM ABS
    14·1 answer
  • In a linux script, the line ____ is important because it identifies the file as a script.
    5·1 answer
  • What is one property of a good hash code?
    11·1 answer
  • What is the most important trait of the first pilot project in the AI Transformation Playbook?
    10·1 answer
  • Which weakness of web sites to launch attacks does an sql injection technique exploit?
    15·1 answer
  • (1) Output a menu of automotive services and the corresponding cost of each service. (2 pts)Ex:Davy's auto shop servicesOil chan
    9·1 answer
  • An alarm clock draws 0.5 A of current when connected to a 120 volt circuit. Calculate its resistance.
    10·1 answer
  • How many constructors are there in the following class declaration?class CashRegister { public: CashRegister(); CashRegister(int
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!