Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Make a basic Java program called Reverser according to the following guidelines.

ID: 3671734 • Letter: M

Question

Make a basic Java program called Reverser according to the following guidelines.

The program prompts the user for two words (strings) from the command line and thenprints the words in reverse order, using one or more for loops to 'walk through' the strings.

For example, if the user enters "supposedly fantastic" your program should print "citsatnaf yldesoppus"(without the quotation marks).Remember to use one or more for loops

Explanation / Answer

import java.util.*; class ReverseString { public static void main(String args[]) { String original, reverse = ""; Scanner in = new Scanner(System.in); System.out.println("Enter a string to reverse"); original = in.nextLine(); int length = original.length(); for ( int i = length - 1 ; i >= 0 ; i-- ) reverse = reverse + original.charAt(i); System.out.println("Reverse of entered string is: "+reverse); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote