SHARE
TWEET

Index of Letters

savovaap_ May 24th, 2019 (edited) 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top