Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JOptionPane;
- public class qwerty
- {
- public static void main(String [] args)
- {
- String input, newInput;
- String Line1 = "qwerrtyuiop", Line2 = "asdfghjkl", Line3 = "zxcvbnm", aCharacter, result = "The Keyboard Lines Used In This Word/Sentence/Phrase Are: \n";
- boolean L1 = false, L2 = false, L3 = false;
- int i;
- input = JOptionPane.showInputDialog(null, "Please enter a word, phrase or sentence: ","Keyboard Line Check", 3);
- if(input.equals(""))
- JOptionPane.showMessageDialog(null,"Please enter a valid word/sentence/phrase");
- else
- {
- newInput = input.replaceAll("[^a-zA-Z]", "");
- newInput = newInput.toLowerCase();
- for(i = 0; i < Line1.length() && !L1; i++)
- {
- aCharacter = Line1.substring(i, i + 1);
- if (input.indexOf(aCharacter) == -1)
- L1 = false;
- else L1 = true;
- }
- for(i = 0; i < Line2.length() && !L2; i++)
- {
- aCharacter = Line2.substring(i, i + 1);
- if (input.indexOf(aCharacter) == -1)
- L2 = false;
- else L2 = true;
- }
- for(i = 0; i < Line3.length() && !L3; i++)
- {
- aCharacter = Line3.substring(i, i + 1);
- if (input.indexOf(aCharacter) == -1)
- L3 = false;
- else L3 = true;
- }
- if(L1)
- result += "Line 1 (QWERTYUIOP)\n";
- if(L2)
- result += "Line 2 (ASDFGHJKL) \n";
- if(L3)
- result += "Line 3 (ZXCVBNM) \n";
- }
- JOptionPane.showMessageDialog(null,result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement