Hey guys, An assignment was given that you allow the user to input an odd number. If it's not odd or greater than 0 they get a invalid number response. You are suppose to create a diamond structure with asteriks like this,
*
***
*
So far i've gotten the user input and printing. But i'm having problems with the spacing and allowing for more than 1 asterik to be shown on the line. Here's what I have to far
CODE
import java.util.Scanner;
public class DiamondPrinter
{
public static void main ( String args[] )
{
Scanner input = new Scanner( System.in );
System.out.print ( "Enter an odd number, 1 or more:");
int diamonds = input.nextInt();
int n = diamonds%2;
int h = diamonds;
int i;
while ( n == 0 || n < 0)
{
int invalid = diamonds;
System.out.printf (" %s is not a valid number, please enter a new number:",invalid);
diamonds = input.nextInt();
n = diamonds%2;
h = diamonds;
}
while (n != 0)
{
for (i = 1; i <= h; ++i)
System.out.println( "*");
}
}
}
Any help on how to get multiple asteriks printed on a line with a user inputted number would help a ton. thanks

.
This post has been edited by Defcon2006: 22 May, 2007 - 05:47 PM