Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4. * @version 18/11/17
  5. * @author Tobi salako
  6. * @aim
  7. */
  8. public class L06CharacterIndexFinder
  9. {
  10.  
  11. public static void main(String[] args)
  12. {
  13. Scanner szKeyboard = new Scanner (System.in);
  14.  
  15. String [] szAlphapet = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","v","w","x","y","z"};
  16. String szWord;
  17. int j = 0;
  18.  
  19.  
  20. System.out.println("Please enter a word of your choice: ");
  21. szWord=szKeyboard.nextLine();
  22.  
  23.  
  24. for(int i = 0; i < szWord.length(); i++ )
  25. {
  26. szWord.charAt(0);
  27. String string1 = Character.toString(szWord.charAt(0));
  28.  
  29.  
  30. if(string1.equals(szAlphapet[j]))
  31. {
  32. System.out.println("The character" +szWord.charAt(i) + " is in position "+j+"of the alphabet letter array");
  33. }
  34.  
  35. j++;
  36. }
  37. }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement