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
Lyrx [107]
3 years ago
9

Write a method called printReverse that accepts a String as its parameter and prints the characters in opposite order. For examp

le, a call of printReverse("hello there!"); should print the following output: !ereht olleh If the empty string is passed, no output is produced. Your method should produce a complete line of output.
Computers and Technology
1 answer:
Eddi Din [679]3 years ago
8 0

Answer:

//Method to reverse user text

public static void printReverse(String text) {

 //Create a variable to hold the reversed string

 //Initialize it to an empty string

 String reversedText = "";

 

 //Create a loop that cycles through each character in the text string

 //Prepend each character to the reversedText string

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

  reversedText = text.charAt(i) + reversedText;

 }

 

 //Display the reversed text

 System.out.println(reversedText);

 

}

Explanation:

Explanation has been given in the code in form of comments.

Hope this helps!

You might be interested in
Which of the following sets of data would be represented best in a histogram
PIT_PIT [208]
I’m sorrry but I can only answer this if I know the following. :(
8 0
4 years ago
Digital art is created by using __?
taurus [48]
A paint or art program on your computer.
7 0
3 years ago
Write a Python program to: ask the user to enter the price of an item. Note: use a while loop to check the validity of the price
garik1379 [7]

Answer:

Hi there Tonyhh! Please find the implementation below.

Explanation:

You can save the below code in a file called "price_discount.py". The code is implemented in python 2.0+. To make it work in Python 3.0+, simply update the code to use "input" rather than "raw_input".

price_discount.py

def calculate_discount(price, quantity):

 total = 0.95 * price * quantity;

 return total;

price = raw_input("Enter a price: ");

try:

 price = int(price);

 while price <= 0:

   print("Input a valid number: ")

   price = raw_input("Enter a price: ");

 quantity = raw_input("Enter a quantity: ");

 try:

   quantity = int(quantity);

   if quantity >= 10:

     print(calculate_discount(price, quantity));

 except ValueError:

   print("Invalid quantity!")

except ValueError:

 print("Invalid input!");

 price = -1;

3 0
3 years ago
Which of the following are best practices that should be done in Photoshop before placing images in InDesign?
SSSSS [86.1K]
I’m pretty sure it’s C good luck luv
8 0
4 years ago
Which osi layer is responsible for combining bits into bytes and bytes into frames?
Nastasia [14]
If you are breaking the computer down try in software it does change after a while
3 0
3 years ago
Other questions:
  • If you choose a career, you will always be satisfied with your work.<br> True<br> False
    7·2 answers
  • Suppose you use Batch Gradient Descent to train a neural network and you plot the training error at every epoch. If you notice t
    7·1 answer
  • Jax needs to write a block of code that will organize a list of items alphabetically. Which function should he use? append() pri
    12·1 answer
  • CJ is developing a new website blogging about cutting-edge technologies for people with special needs. He wants to make the site
    8·1 answer
  • Package Newton’s method for approximating square roots (Case Study: Approximating Square Roots) in a function named newton. This
    7·1 answer
  • In Word, the mailing list is known as the ​
    12·1 answer
  • What is the best definition of a network?
    14·2 answers
  • Using complete sentences post a detailed response to the following.
    15·1 answer
  • Choose the correct color to complete the sentence.
    15·1 answer
  • The PowerPoint view in which you can edit the slide master is called ______________.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!