Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class GetBigWords {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- String[] array = new String [50];
- String sentence = "There are 87,000,000 people in Canada";
- int sentenceLength = sentence.length();
- int k=0; // counter for the array, "array"
- int h=0; // counter for first time inserting into array -- may not need!!
- // STEP ONE
- for (int i = 0; i<sentenceLength; i++) // set up the array with the words
- {
- if (array[k] == null) // make sure to empty the slot of the array element first!!
- {
- array[k] = "";
- }
- if(sentence.charAt(i) != (' ')) // as long as we haven't reached a space,
- // update the string in the array with the new string
- {
- array[k] = array[k] + sentence.charAt(i);
- }
- else
- {
- k += 1; // go to the next spot to get the next word
- }
- }
- // Step 2
- int l = 0;
- for (int i = 0; i<array.length; i++)
- {
- int wordLength = array[i].length();
- boolean numberCheck = false;
- for (k = 0; k<array.length; k++) // check if the string is a number
- {
- char digit = array[i].charAt(0);
- if(isDigit(digit))
- {
- numberCheck = true;
- }
- }
- if (wordLength > 5 && numberCheck == false)
- {
- System.out.println(array[i]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement