SvetlozarDragnev

Untitled

Mar 5th, 2025
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. package TextProcessingLab;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class ReverseString01 {
  6.     public static void main(String[] args) {
  7.  
  8.         Scanner scanner = new Scanner (System.in);
  9.  
  10.         String word = scanner.nextLine();
  11.  
  12.  
  13.         while (!word.equals("end")){
  14.             String newWord = "";
  15.             for (int i = word.length()-1; i >= 0 ; i--) {
  16.  
  17.                 char newWordChars = word.charAt(i);
  18.                 newWord += newWordChars;
  19.             }
  20.             System.out.println(word + " = " + newWord);
  21.             word = scanner.nextLine();
  22.             newWord = "";
  23.         }
  24.  
  25.  
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment