micher43

E6.2 part D

Oct 24th, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. import java.util.*;
  2.  
  3.  
  4. public class E62 {
  5.  
  6.     public static void main(String[] args) {
  7.         Scanner s = new Scanner(System.in);
  8.         System.out.println("enter your input");
  9.        
  10.        
  11.  
  12.         String input = s.nextLine();
  13.        
  14.  
  15.         for(int i=0; i < (input.length() - 2); i+=2)
  16.         {
  17.             char first = input.charAt(i);
  18.             char second = input.charAt(i+2);
  19.             if(first == second )
  20.             {
  21.                 System.out.print(Character.toString(first));
  22.             }
  23.            
  24.            
  25.         }
  26.        
  27.  
  28.     }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment