Advertisement
KechevD

Kursova2_IndeksNaBukva

Jun 10th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class IndexOfLetter {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. String input = scanner.nextLine().toLowerCase();
  8.  
  9. char[] letters = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  10.  
  11.  
  12. for (int i = 0; i < input.length() ; i++) {
  13.  
  14. char symbol = input.charAt(i);
  15.  
  16. int position = new String(letters).indexOf(symbol);
  17.  
  18. System.out.printf("%c -> %d%n",symbol,position);
  19. }
  20.  
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement