import java.util.Scanner; public class Task2 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter a string to reverse: "); String input = scanner.nextLine(); String reversed = ""; // Reverse the string using a for loop for (int i = input.length() - 1; i >= 0; i--) { reversed += input.charAt(i); } // Print the reversed string System.out.println("Reversed String: " + reversed); scanner.close(); } }