For my assignment I am supposed to make a Draw a diamond with asterisks using methods.
I figured out how to make the first part (centered triangle)
I cannot for the love of God figure it out. I have spent over 4 hours trying different things and I figured how to make an upside down triangle, but the diamond is not working out.
This is what I have for the first part. Can someone tell me how to flip it so that it will form a diamond when used with an upside down version?
{
int rows = userInputHeight;
int starCount = 1;
int spaceCount = rows - 1;
for( int rowCount = 1; rowCount <= rows; rowCount++ )
{
for( int numb = 1; numb <= spaceCount; numb++ )
{
System.out.print(" ");
}
for( int count = 1; count <=starCount; count++ )
{
System.out.print("*");
}
System.out.println();
starCount += 2;
spaceCount--;
}
}
This is what it displays (UserInputHeight = 10):
*
***
*****
*******
*********
***********
This is what I want (UserInputHeight = 19):
*
***
*****
*******
*********
***********
***********
*********
*******
*****
***
*
This is what I have so far for the second part:
{ int rows = userInputHeight;
int starCount = rows*2;
int spaceCount =userInputPadding;
if (userInputHeight % 2 == 0)
{
userInputHeight+=1;
}
for (int rowCount = rows; rowCount >= 1; rowCount --)
{
for (int i = 0; i <= (rows - rowCount)+ spaceCount; i++)
{
System.out.print(' ');
}
for (int i = 1; i < starCount; i++)
{
System.out.print('*');
}
System.out.println();
starCount -=2;
}
}
Please help.