Guest User

Untitled

a guest
May 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. public class WordBoolean {
  2. private static final String[] FIRST_ROW = {"q", "w", "e", "r", "t", "y", "u", "i", "o", "p"};
  3. private static final String[] SECOND_ROW = {"a", "s", "d", "f", "g", "h", "j", "k", "l"};
  4. private static final String[] THIRD_ROW = {"z", "x", "c", "v", "b", "n", "m"};
  5.  
  6. public boolean wordCheck(String word) {
  7. int char_count = word.length();
  8. int counter1 = 0;
  9. int counter2 = 0;
  10. int counter3 = 0;
  11.  
  12. String[] arrWord = word.split("");
  13.  
  14. for (int i = 0; i < char_count; i++) {
  15. for (String element : FIRST_ROW) {
  16. if (arrWord[i].equals(element)) {
  17. counter1 = counter1 + 1;
  18. }
  19. }
  20. }
  21.  
  22. for (int i = 0; i < char_count; i++) {
  23. for (String element : SECOND_ROW) {
  24. if (arrWord[i].equals(element)) {
  25. counter2 = counter2 + 1;
  26. }
  27. }
  28. }
  29.  
  30. for (int i = 0; i < char_count; i++) {
  31. for (String element : THIRD_ROW) {
  32. if (arrWord[i].equals(element)) {
  33. counter3 = counter3 + 1;
  34. }
  35. }
  36. }
  37.  
  38. if (counter1 == char_count ||
  39. counter2 == char_count ||
  40. counter3 == char_count) {
  41. return true;
  42. }
  43. return false;
  44. }
  45.  
  46. public static void main(String[] args) {
  47. WordBoolean newWord = new WordBoolean();
  48. System.out.print(newWord.wordCheck("qwer"));
  49.  
  50.  
  51. }
  52. }
Add Comment
Please, Sign In to add comment