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
What is the nearest inhabited area to the amazon rainforest
TEA [102]
There are inhabited areas INSIDE the Amazon Rainforest. Many primitive tribes with little to no contact of the outside world live in remote areas of the rainforest, but the closest major city to the rainforest (also inside) is Manaus, Brazil.
4 0
3 years ago
Write an algorithm to print the minimum and maximum of an integer array. Your need to pass the array as a parameter. Since we ca
sammy [17]

Answer:

See explaination

Explanation:

MinMax.java

import java.util.*;

public class MinMax

{

static void MinMax(int[] arr)

{

int Min=arr[0]; // initializinf min and max with 1st value of array

int Max=arr[0];

for(int i=0;i<arr.length;i++) // iterating loop only once

{

if(arr[i]>Max) // checking max value

{

Max=arr[i];

}

if(arr[i]<Min) // checking min value

{

Min=arr[i];

}

}

System.out.println("Min Number is "+Min); //printing min value

System.out.println("Max Number is "+Max); //printing max value

}

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.print("Enter N value: "); // taking n value

int n=sc.nextInt();

int[] arr=new int[n];

System.out.println("Enter N elements:"); // taking n elements into array

for(int i=0;i<n;i++)

{

arr[i]=sc.nextInt(); // each element into the array

}

MinMax(arr); // calling MinMax() method.

}

}

4 0
3 years ago
The _____ method of developing systems produces code that is modular and reusable.
Ymorist [56]

The object-oriented analysis method of developing systems produces code that is modular and reusable.

<h3>What is object oriented system analysis?</h3>

Object-oriented systems analysis and specification (OSA) is known to be a kind of a method that is often used in regards to systems analysis and this is known to be one that helps to create or builds on the strengths of former systems and, at also at the same time, look into their weaknesses.

Note that this is said to be the basic idea behind the OSA methodology that are known to be described. The framework of OSA system models is known to be object class.

Hence, The object-oriented analysis method of developing systems produces code that is modular and reusable.

Learn more about object-oriented  tool from

brainly.com/question/11158544

#SPJ1

8 0
2 years ago
Why did utf 8 replace the sac character encoding standard
Sedaia [141]
UTF-8- is a variable width character encoding capable of encoding all 1,112,064 valid code points in Unicode using one to four 8-bit bytes. The encoding is defined by the Unicode standard. The sac character encoding method was addressed to simplify the symbolism of letter and symbols.As the computers grew in capacity UTF-8 method was implemented to optimize such protocol allowing more characters to be included with an expanded string of possibilities
7 0
3 years ago
Fill in the blank by selecting the correct option. Ethical codes may not address because they are written quite broadly
gogolik [260]

Ethical codes may not address all of organization's ethics because they are written mostly by a task force committee of SHRM members and leaders.

<h3>What does codes of ethics address?</h3>

A code of ethics are known to have or contains some professional conduct outlines. They are regarded as ethical principles that helps to rule  or monitors decisions and behavior at a firm.

They are known to states the  general ways of how employees should behave in the office , as well as some other guidance for settling issues such as harassment, safety, etc.

Learn more about  Ethical codes  from

brainly.com/question/24606527

4 0
2 years ago
Other questions:
  • Distinguish among packet filtering firewalls, stateful inspection firewalls, and proxy firewalls. A thorough answer will require
    9·1 answer
  • Write thanks to the IT teacher at the end of grade 5
    7·1 answer
  • Why is it important to know who reviews the information posted on a Web site?​
    15·1 answer
  • If you are viewing a webpage with customized or regenerated content, such as updated stock quotes, what type of webpage are you
    14·1 answer
  • Write the definition of a function that takes as input the three numbers. The function returns true if the first number to the p
    12·1 answer
  • Create a recursive method, a method that calls itself, that returns the number of vowels that appear in any string given. Keep i
    11·1 answer
  • Write a method that determines the total number of chars in each string of an array.
    12·1 answer
  • Research and describe a recent development in theater and film lighting and explain how the technology can be used. (Maybe limit
    8·2 answers
  • Anyone wanna join zoo m???????​
    10·2 answers
  • Simple example of hybrid computer​
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!