Originally I had the program all in main but I wanted to separate this by having the comparison method (diamond of asterisks) in its own method. For some odd reason I'm getting weird errors that won't allow the program to run.
Errors below:
1) Systan error on token "," delete this token
2) Sytax error on token "}" delete this token
3) Syntax error on token "k," variable declared...
4) Syntax error again!
Any help would be appreciated...
import javax.swing.JOptionPane;
public class Diamond
{
public static void main(String[] args)
{
String rowNum;
int row; //# of rows "odd"
int n, i, j,k;
//display message
rowNum = JOptionPane.showInputDialog("Enter a ODD number");
row = Integer.parseInt(rowNum);
// assign input number to n
n = row;
//display value entered
System.out.println("The number entered was " + n + " below you will find your diamond.");
diamondOFAsterisks();
}
}
static void diamondOFAsterisks(int n, i, j, k)
{
for(i = 1; i < n/2; i++)
{
for (k = n; k > i; k--)
System.out.print(" ");
for (j = 1; j <= i; j++)
System.out.print("" + " ");
System.out.println();
}
for(i = n/2)+1; i > 0; i--)
{
for(k=n; k > i; k--)
System.out.print(" ");
for(j = 1; j <= i; j++)
System.out.print("*" + " ");
System.out.println();
}
}
}