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
Rom4ik [11]
3 years ago
9

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. in java.
Computers and Technology
1 answer:
OLEGan [10]3 years ago
6 0

Answer:

The solution code is as below:

  1.        Scanner input = new Scanner(System.in);
  2.        System.out.print("Input a string: ");
  3.        String inStr = input.nextLine();
  4.        int strLen = inStr.length();
  5.        while(inStr.equals("Quit") != true && inStr.equals("quit") !=true && inStr.equals("q") != true){
  6.            for(int i= 0; i < strLen; i++){
  7.                System.out.print(inStr.charAt(strLen - 1 - i));
  8.            }
  9.            System.out.println();
  10.            System.out.print("Input a string: ");
  11.            inStr = input.nextLine();
  12.            strLen = inStr.length();

Explanation:

Firstly, we create a Scanner object,<em> input</em> (Line 1).

Next, we use the Scanner object nextLine() method to get a text input from user (Line 3).

We create a while loop and set the condition so long as the input text is not equal to "Quit", "quit" or "q" (Line 6), the program should proceed to print the input text in reverse (Line 8-10). To print the text in reverse, we can apply the expression<em> length of string - 1 - current index</em>.  This will ensure the individual letter is read from the last and print the text in reverse.

Next, prompt the user to input a new text (Line 13-14) and repeat the same process of printing text in reverse so long as the current input text is not "Quit", "quit" or "q".

You might be interested in
A(n) ________ is often developed by identifying a form or report that a user needs on a regular basis.
MariettaO [177]

A <u>user view</u> is often developed by identifying a form or report that an end user needs on a regular basis.

<h3>What is a database?</h3>

A database can be defined as an organized and structured collection of factual data that are stored on a computer system as a backup and are usually accessed electronically.

In database management system (DBMS), a <u>user view</u> is often developed by a software developer through an identification of a form or report that an end user needs on a regular basis.

Read more on data here: brainly.com/question/13179611

#SPJ1

4 0
1 year ago
Have y’all enjoyed The new hero floryn from Mobile legends
Angelina_Jolie [31]

Answer:

yo! but I'm a ex-mobile legends

5 0
2 years ago
Common features of a thunderstorm are _____. thunder lightning rain or hail all of the above
Semmy [17]
All of the above
---------------------------------

8 0
3 years ago
Read 2 more answers
1. Write a function that will ask the user to enter a value in dollars. The function should calculate and display the equivalent
julia-pushkina [17]

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

   

    valueInDollars();

}

   public static void valueInDollars() {

       double currentMoney, quarters, dimes, nickels, pennies;

       Scanner input = new Scanner(System.in);

       

       System.out.print("Enter a value in dollars: ");

       currentMoney = input.nextDouble();

       currentMoney *= 100;

       quarters = (int)currentMoney / 25;

       currentMoney = currentMoney % 25;

       

       dimes = (int)currentMoney / 10;

       currentMoney = currentMoney % 10;

       

       nickels = (int)currentMoney / 5;

       currentMoney = currentMoney % 5;

       

       pennies = currentMoney;

       

       System.out.print("Quarters: " + quarters + "\n" + "Dimes: " + dimes + "\n" + "Nickels: " + nickels + "\n" + "Pennies: " + pennies);

   }

}

Explanation:

<u>Inside the function:</u>

- Declare the variables

- Ask the user for a value in dollars

- Multiply that value by 100

- Find the amount of quarters, dimes, nickels, and pennies

- Print the values

<u>Inside the main:</u>

- Call the function

3 0
3 years ago
How do u answer questions on brainly if ur on the app and on a phone. For me there is no answer button :(
Rudik [331]

Answer:

oh for me there is maybe try reloading?

Explanation:

8 0
2 years ago
Other questions:
  • Which of the following is NOT an option in the comments group
    12·1 answer
  • Please help me please and thank you!
    14·1 answer
  • Which option marks all modification made within a document? Review Comment Track Changes Balloons
    15·2 answers
  • Host A is sending Host B a large le over a TCP connection. Assume Host B has no data to send Host A. Host B will not send acknow
    14·1 answer
  • What is 450 g of flour a measure of?
    11·1 answer
  • An Organization Chart to support the Appliance Warehouse case study The SWOT Analysis diagram you performed and created to suppo
    13·1 answer
  • write a java program using a do while loop to prompt the user to enter a password. The user should be prompted to enter the pass
    5·1 answer
  • Portable Document Format (PDF) is a file format that provides an electronic image of a document and can be viewed, printed, and
    12·2 answers
  • Which of the following transfer rates is the FASTEST?
    15·1 answer
  • A letter of application should be written on:
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!