Advertisement
veronikaaa86

01. Reverse Strings

Mar 8th, 2023
760
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. package textProcessing;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P01ReverseStrings {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         String text = scanner.nextLine();
  10.         while (!text.equals("end")) {
  11.             String reverseWord = "";
  12.             for (int i = text.length() - 1; i >= 0; i--) {
  13.                 char symbol = text.charAt(i);
  14.                 reverseWord = reverseWord + symbol;
  15.             }
  16.  
  17.             System.out.printf("%s = %s%n", text, reverseWord);
  18.  
  19.             text = scanner.nextLine();
  20.         }
  21.     }
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement