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
eimsori [14]
4 years ago
14

4.24 LAB: Print string in reverse Write a program that takes in a line of text as input, and outputs that line of text in revers

e. The program repeats, ending when the user enters "Quit", "quit", or "q" for the line of text. Ex: If the input is:
Computers and Technology
1 answer:
tresset_1 [31]4 years ago
7 0

Answer:

See explaination

Explanation:

import java.util.Scanner;

public class LabProgram {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

String line;

while (true) {

line = in.nextLine();

if (line.equals("quit") || line.equals("Quit") || line.equals("q")) break;

for (int i = 0; i < line.length(); i++) {

System.out.print(line.charAt(line.length() - i - 1));

}

System.out.println();

}

}

}

You might be interested in
What are the careers needed to create a video game? Name all the careers involved please.
AURORKA [14]
Audio Engineers
Interpreters and Translators
Video Game Testers
Technical Support Specialists
Marketing Managers
Market Research Analysts
Sales Representatives

6 0
4 years ago
Ask the user to type in an integer greater than 50 and assign it to a variable called x. Write a program to calculate the sum of
Zinaida [17]

Answer:

The solution in Python is as follows:

<em>num = int(input("Number: "))</em>

<em>if num>50:</em>

<em>     sum = 0</em>

<em>     count = 0</em>

<em>     for i in range(1,num):</em>

<em>          count = count + 1</em>

<em>          sum = sum + i**2</em>

<em>          if sum > num:</em>

<em>               sum = sum - i**2</em>

<em>               count = count - 1</em>

<em>               break;</em>

<em>    </em>

<em>     print("Sum: "+str(sum))</em>

<em>     print("Numbers: "+str(count))</em>

<em>else:</em>

<em>     print("Number must be greater than 50")</em>

<em />

Explanation:

The condition stated in the question do not conform with the example. The question says, the loop should stop when sum > x.

But:

When x = 100 and sum = 91, the program loop should not stop because 91 is not greater than 100.

However, I'll answer based on the example given in the question.

This prompts user for number

num = int(input("Number: "))

The following if condition is executed if number is greater than 50

if num>50:

This initializes sum to 0

    sum = 0

This initializes count to 0

    count = 0

The iterates through the inputted number (e.g. 100)

    for i in range(1,num):

This increases the count

         count = count + 1

This calculates the sum of square of the positive integer

         sum = sum + i**2

The following removes excess number from the sum

<em>          if sum > num:</em>

<em>               sum = sum - i**2</em>

<em>               count = count - 1</em>

<em>               break;</em>

This prints the calculated sum    

    print("Sum: "+str(sum))

This prints the count of number used

    print("Numbers: "+str(count))

The following is executed if user input is less than 50

<em>else:</em>

<em>     print("Number must be greater than 50")</em>

<em />

<em></em>

3 0
3 years ago
Which of the following terms BEST describes the act of animating an object?
Whitepunk [10]
Bump mapping is right answer
7 0
3 years ago
Read 2 more answers
Which type of classroom enables students to attend lectures without being physically present with the teacher?
Kisachek [45]
An online class? I think lol
5 0
4 years ago
Select the correct answer.
siniylev [52]

Answer:A

Explanation: J pegs are easily saved and accessed anywhere and show good quality

8 0
3 years ago
Other questions:
  • Your friends parents are worried about going over their budget for the month. Which explains would you suggest is not a need.
    14·2 answers
  • what would happen if a large number of computer users are attempting to access a web site at the same time that you are
    15·2 answers
  • The partners of a small architectural firm are constantly busy with evolving client requirements. To meet the needs of their cli
    11·1 answer
  • Use fuel with the _____________ rating recommended by your vehicle manufacturer. A ) Converter B) Emission C) Exhaust D) Octane
    9·2 answers
  • Stored information about a previous visit to a web site is called information _____.
    10·1 answer
  • Please Help me no links.
    6·1 answer
  • Two things every professional PowerPoint presentation should have
    8·1 answer
  • What will the following program display in the console?
    13·2 answers
  • What practice makes it virtually impossible to figure out the geographic location of a company?
    7·1 answer
  • File format extension for animation are. Swf,. Swl and _____
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!