Advertisement
MelindaElezovic

ForLoopyString

Jan 13th, 2016
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. //melinda
  2. //1.12.16
  3. import java.util.*;
  4.  
  5. public class ForLoopyString
  6. {
  7.   public static void main(String[] args)
  8.   {
  9.     Scanner input = new Scanner(System.in);
  10.     System.out.print("Enter a word: ");
  11.     String word = input.nextLine();
  12.    
  13.     int length=word.length();
  14.     System.out.println(word.charAt(0));
  15.     System.out.println(word.charAt(length-1));
  16.                        for(int i = length; i>=1; i--){
  17.                          System.out.print(word.charAt(i-1));
  18.                        
  19.   }
  20.                        System.out.println("\n"+word);
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement