answer.
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
mestny [16]
2 years ago
10

Write a method that accepts a String object as an argument and displays its contents backward. For instance, if the string argum

ent is "gravity" the method should display "ytivarg". Demonstrate the method in a program that asks the user to input a string and then prints out the result of passing the string into the method.
Computers and Technology
1 answer:
Nata [24]2 years ago
6 0

Answer:

// importing the necessary libraries

import java.util.Scanner;

public class BackwardString {

public static void main(String[] args) {

String input;

// Scanner object to read string from user input

Scanner scanner = new Scanner(System.in);

System.out.print("Enter String here : ");

input=scanner.next();

// calling backward method to reverse passed string

backward(input);

// closing Scanner object

scanner.close();

}

// Method to Reverse the input string

private static void backward(String source) {

int i, len = source.length();

StringBuilder dest = new StringBuilder(len);

for (i = (len - 1); i >= 0; i--){

dest.append(source.charAt(i));

}

System.out.println("Reversed String : "+dest);

}

}

Explanation:

// importing the necessary libraries

import java.util.Scanner;

public class BackwardString {

public static void main(String[] args) {

String input;

// Scanner object to read string from user input

Scanner scanner = new Scanner(System.in);

System.out.print("Enter String here : ");

input=scanner.next();

// calling backward method to reverse passed string

backward(input);

// closing Scanner object

scanner.close();

}

// Method to Reverse the input string

private static void backward(String source) {

int i, len = source.length();

StringBuilder dest = new StringBuilder(len);

for (i = (len - 1); i >= 0; i--){

dest.append(source.charAt(i));

}

System.out.println("Reversed String : "+dest);

}

}

The program above accepts a String object as an argument and displays its contents backward.

It reverses the any string inputed while producing the output.

You might be interested in
Initialize the list short_names with strings 'Gus', 'Bob', and 'Zoe'. Sample output for the given program:
ohaa [14]

Answer:

Following are the correct code to this question:

short_names=['Gus','Bob','Zoe']#defining a list short_names that holds string value

print (short_names[0])#print list first element value

print (short_names[1])#print list second element value

print (short_names[2])#print list third element value

Output:

Gus

Bob

Zoe

Explanation:

  • In the above python program code, a list "short_names" list is declared, that holds three variable that is "Gus, Bob, and Zoe".
  • In the next step, the print method is used that prints list element value.
  • In this program, we use the list, which is similar to an array, and both elements index value starting from the 0, that's why in this code we print "0,1, and 2" element value.
7 0
1 year ago
Write a static generic method PairUtil.minmax that computes the minimum and maximum elements of an array of type T and returns a
Gnesinka [82]

Answer:

Explanation:

The following code is written in Java. It is hard to fully create the code without the rest of the needed code including the T class and the Measurable interface. Regardless the following code can be implemented if you have that code available.

 public static T minmax(ArrayList<T> mylist) {

       T min = new T();

       T max = new T();

       for (int x = 0; x < mylist.size(); x++) {

           if (mylist.get(x) > max) {

               max = mylist.get(x);

           } else if (mylist.get(x) < min) {

               min = mylist.get(x);

           }

       }

       

       return (min, max);

   }

5 0
2 years ago
Jason has decided to use his name on all the images to protect them from misuse. He has also decided to use the logo of his comp
Mila [183]

Answer:

Text watermarking involves adding the photographer's name at the corner of the image.

Explanation:

This was one of the correct answers when I took the test, I got it wrong because I didn't pick all the correct answers. I hope that this was helpful to you! If you know the other correct answer(s) please comment and let me know and i'll edit this answer! :)

6 0
2 years ago
Read 2 more answers
What is illustrated in the cells to the right of the Fourth Quarter column?
beks73 [17]
Photosynthesis is illustrated in the cells to the right of the fourth column
5 0
2 years ago
Read 2 more answers
When a product owner adds a new feature/idea in the backlog and brings it up for discussion during refinement session, how shoul
Drupady [299]

Answer:

2 is the correct answer.

5 0
2 years ago
Read 2 more answers
Other questions:
  • Computer hardware without software is useless while computer software without hardware is meaningless. Discuss. Plz provide exam
    15·1 answer
  • HELP PLEASE ASAP brainliest to accurate
    14·2 answers
  • Which option describes wearable technology? A. the incorporation of technology into objects we use regularly B. rugged technolog
    8·1 answer
  • You have been tracking your exercise routine, which involves running, lifting weights, yoga, and stretching. You want to see wha
    15·2 answers
  • 8. In time series, which of the following cannot be predicted? A) large increases in demand B) technological trends C) seasonal
    11·1 answer
  • You have installed a point-to-point connection using wireless bridges and Omni directional antennas between two buildings. The t
    9·1 answer
  • An administrator has been working within an organization for over 10 years. He has moved between different IT divisions within t
    8·1 answer
  • Nstructions
    7·1 answer
  • A line graph titled Unemployment Percentages and Levels of Education where the x-axis shows dates from November 2007 to November
    11·1 answer
  • George has to present the goals of information management to his team member. What is a goal of information management? The goal
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!