Write a method that accepts a String object as an argument and displays its contents backward.
For instance, if the string argument is “gravity” the method should display -“ytivarg”.
Demonstrate the method in a program that asks the user to input a string and then passes it
to the method.
A Java program to reverse the given string is as follows,
//Create a class
//Define the main() function
public static void main(String args)
//Declare String variable
//Create Scanner object
Scanner in=new Scanner(System.in);
//Prompt the user to enter the string
System.out.print("Enter the string: ");
//Get the input from the user
//Call the method to reverse
//Exit the program
//Define the method to reverse the string
public static void RevString(String str)
/*Create for loop to display the string reverse*/
for (int i=str.length()-1;i>=0;i--)
//Print the character in the string
Screenshot of program #1:
Screenshot of program #2...
Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*See Solution
Q: A laser beam 1 mm wide is aimed at a detector 1 mm wide 100 m away on the roof of a building. How mu...
A: Formula for determining the angular diversion of laser before it misses the detector is given below-
Q: • Create a Scanner (note which line the user inputs and presses enter)• Asks the user to enter the n...
A: The algorithm for the program would be as below:Prompt the user for the inputAccept the user inputCo...
Q: Write the following Book class:A Book has-a title, ISBN number, author and price.o Include the follo...
A: All the lines inside this (/* */) field are comments of this program. Read all comments above the co...
Q: how do I Write a String constant consisting of exactly 5 exclamation marks. in python language
A: String Constants: The string constant is nothing but the sequences of characters that is used as dat...
Q: perform a What-If Analysis on the amount of Saving based on your own scenario.
A: What-if analysis is a backward processing in which, a specific output is provided to find out the in...
Q: a. Assuming that x is 1, show the result of the following Boolean expressions.(true) && (3 &...
A: a. The result for the following Boolean expressions:Assuming x = 1(true) && (3 > 4)3 is n...
Q: Write a program in Eclipse that contains 2 methods, main and printLine.
A: Program plan: Import necessary packages.Define a class named “PrintCheck”.Define a method called “pr...
Q: For the following problems assume 1 kilobyte (KB) 1024 kilobytes. 1024 bytes and 1 megabyte (MB) For...
A: (a) The last bits of virtual address are called offset. And for a 4K page, the number of bits will b...
Q: What is the reduced form of the function F X(XY)+X(X+Y)? a) Y b) X c) 0 d) 1
A: Reduction:The reduced form of the function “F” is computed as follows: