{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

WordCross - for(int l =0 l< first.length l a =(d[i == c[l...

Info icon This 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++){
Image of page 1

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

View Full Document Right Arrow Icon
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 < 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 < second.length()){ if(v == j){ for(int k=0; k< first.length(); k++){ System.out.print(c[k]);} System.out.println(); } for(int i=0; i<=h-1; i++ ){ System.out.print(" "); } s = j; if(j == v){ ++s; System.out.println(d[s]); j++; j++; } else{ System.out.println(d[j]); j++; } } } }...
View Full Document

{[ snackBarMessage ]}