Advertisement
savovaap_

Index of Letters

May 24th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class IndexOfLetters {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         char[] alphabet = new char[26];
  8.         for (int i = 0; i < 26; i++) {
  9.             alphabet[i] = (char)('a' + i);
  10.         }
  11.  
  12.         String word = scanner.nextLine().toLowerCase();
  13.         for (int i = 0; i < word.length(); i++) {
  14.             for (int j = 0; j < alphabet.length; j++) {
  15.                 if (word.charAt(i) == alphabet[j]) {
  16.                     System.out.println(word.charAt(i) + " -> " + j);
  17.                 }
  18.             }
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement