SixKangaroo - couldBe += wordTwo.substring(i, END);...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.io.PrintStream; i public class SixKangaroo { public static void main(String[] args) { PrintStream out = System.out; out.printf("%s %s are ", args[0], args[1]); String wordOne = args[0].toLowerCase(); String wordTwo = args[1].toLowerCase(); String couldBe = ""; boolean isKangaroo = false; for (int i = 0; i < wordTwo.length(); i++) { final int END = i + 1;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: couldBe += wordTwo.substring(i, END); isKangaroo = wordOne.contains(wordTwo.substring(i, END)) && couldBe.equals(wordTwo.substring(0, END)) ? true : false; i = isKangaroo ? i : wordTwo.length(); } if (isKangaroo) { out.printf("Kangaroo words.%n"); } else { out.printf("not Kangaroo words.%n"); } } }...
View Full Document

This note was uploaded on 09/16/2011 for the course CSE CSE 1020 taught by Professor Burton,ma during the Fall '10 term at York University.

Ask a homework question - tutors are online