View Single Post
  #3 (permalink)  
Old 11-06-2007, 04:29 AM
confused2000 confused2000 is offline
Member
 
Join Date: Nov 2007
Posts: 3
confused2000 is on a distinguished road
got this so far, but the square is not hollow, HELP!!
__________________________________________________ ______________

import java.util.Scanner;

public class HollowSquare2 {
public static void main(String[] args) {

Scanner keyInput = new Scanner(System.in);


int lo = 1;
int hi = 20;
int squareSize;

int rowCounter = 0;
int columnCounter = 0;

do
{

System.out.print("Enter the square size from 1 - 20: ");
squareSize = keyInput.nextInt();
}
while (squareSize >= lo ^ squareSize <= hi);

while (rowCounter < squareSize)
{
// Loop produce columns
while (columnCounter < squareSize)
{
if (rowCounter % 2 == 0)
{
System.out.print("X");
}
else
System.out.print("X");
columnCounter++;
}

// Increment and reset for the next row
rowCounter++;
columnCounter = 0;
System.out.println();
}






}
}
Reply With Quote