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

Task 2 (12 pts) Project name: HW4_ReverseString Write a program that reads a str

ID: 1883056 • Letter: T

Question

Task 2 (12 pts) Project name: HW4_ReverseString Write a program that reads a string from the user, and creates another string with the letters from it in reversed order. You should do this using string concatenation and loops. Do not use any method from Java that does the work for you. The reverse string must be built. Do not just print the letters in reversed order. Instead, concatenate them in a string. Components to this problem: 1. Can you make a copy a string? Go through the letters one by one and copy them in another string? 2. Can you iterate through a string int reverse order? Print it to the screen to check it out. 3. Combine the above. -Sample run: This program will create a string with letters in reversed order. Enter a string: cat The reversed string is: tac Bye Sample run: This program will create a string with letters in reversed order. Enter a string: cats and dogs The reversed string is: sgod dna stac Bye

Explanation / Answer

public class ReverseString { public static void main(String[] args) { String str = "Hello Java"; for (int i = str.length() - 1; i >= 0; i--) { System.out.print(str.charAt(i)); } } }

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