/*
*
Enter an even number : 4
* * * *
* *
* *
* * * *
*/
/*
* No negative inputs please
*/
/**
* A quote: there are more than one ways to do it
*/
package javaapplication2;
import java.util.Scanner;
/**
*
* @author Umang
*/
public class Main
{
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
// loop variables
int j = 0, k = 0;
Scanner s = new Scanner(System.in);
System.out.print("Enter a number : ");
int n = s.nextInt();
System.out.print("\n");
for (j = 0; j < n; j++)
{
for (k = 0; k < n; k++)
{
if (k == 0 || k == n - 1 || j == 0 || j == n - 1)
{
System.out.print(" * ");
}
else
{
System.out.print(" ");
}
}
System.out.print("\n");
}
}
}
Sunday, March 13, 2011
Pattern Program
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment