WordCross - for(int l =0; l < first.length();...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
package lab06; import java.util.Scanner; i public class WordCross { p public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("Please enter two words: "); String first = in.next(); String second = in.next(); char[] c = new char[first.length()]; char[] d = new char[second.length()]; for(int i =0; i < first.length(); i++){ c[i] = first.charAt(i); } for(int j = 0; j < second.length(); j++){ d[j] = second.charAt(j); } int h =0, v=0; boolean a = false; for(int i = 0; i < second.length(); i++){
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: for(int l =0; l &lt; first.length(); l++){ a = (d[i] == c[l]); if(a == true){ h = l; //spaces v = i; //spaces before vertical word break; } } if(a == true){ break; } } int j=0, s =0;; while(j &lt; second.length()){ if(v == j){ for(int k=0; k&lt; first.length(); k++){ System.out.print(c[k]);} System.out.println(); } for(int i=0; i&lt;=h-1; i++ ){ System.out.print(&quot; &quot;); } s = j; if(j == v){ ++s; System.out.println(d[s]); j++; j++; } else{ System.out.println(d[j]); j++; } } } }...
View Full Document

This note was uploaded on 09/20/2011 for the course COM SCI 227 taught by Professor Staff during the Spring '11 term at Iowa State.

Page1 / 2

WordCross - for(int l =0; l &amp;amp;lt; first.length();...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online