Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2. public class qwerty
  3. {
  4. public static void main(String [] args)
  5. {
  6. String input, newInput;
  7. String Line1 = "qwerrtyuiop", Line2 = "asdfghjkl", Line3 = "zxcvbnm", aCharacter, result = "The Keyboard Lines Used In This Word/Sentence/Phrase Are: \n";
  8. boolean L1 = false, L2 = false, L3 = false;
  9. int i;
  10. input = JOptionPane.showInputDialog(null, "Please enter a word, phrase or sentence: ","Keyboard Line Check", 3);
  11.  
  12.  
  13. if(input.equals(""))
  14. JOptionPane.showMessageDialog(null,"Please enter a valid word/sentence/phrase");
  15. else
  16. {
  17. newInput = input.replaceAll("[^a-zA-Z]", "");
  18. newInput = newInput.toLowerCase();
  19. for(i = 0; i < Line1.length() && !L1; i++)
  20. {
  21. aCharacter = Line1.substring(i, i + 1);
  22. if (input.indexOf(aCharacter) == -1)
  23. L1 = false;
  24. else L1 = true;
  25. }
  26.  
  27. for(i = 0; i < Line2.length() && !L2; i++)
  28. {
  29. aCharacter = Line2.substring(i, i + 1);
  30. if (input.indexOf(aCharacter) == -1)
  31. L2 = false;
  32. else L2 = true;
  33. }
  34.  
  35. for(i = 0; i < Line3.length() && !L3; i++)
  36. {
  37. aCharacter = Line3.substring(i, i + 1);
  38. if (input.indexOf(aCharacter) == -1)
  39. L3 = false;
  40. else L3 = true;
  41. }
  42. if(L1)
  43. result += "Line 1 (QWERTYUIOP)\n";
  44. if(L2)
  45. result += "Line 2 (ASDFGHJKL) \n";
  46. if(L3)
  47. result += "Line 3 (ZXCVBNM) \n";
  48. }
  49. JOptionPane.showMessageDialog(null,result);
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement