How do i do this kind of program in java?
Enter a Number: 5
*
**
***
****
*****
****
***
**
*
Process Completed.
Enter a Number: 5
*
**
***
****
*****
****
***
**
*
Process Completed.
public class Stars{
char star = '*';
char[][]st;
public Stars(int cnl1) {
st = new char [cn1][cn1];
for (int i=0; i < cnl1;i++)
for (int j = 0; j <cn 1;j++)
st [i][j] =star ;
}
void starsShow() {
for (int i=0; i < st.length;i++)
for (int j = 0; j < st.length;j++){
System.out.print(st[i][j]);
if(j==st.length-1)
System.out.println("");
}
}
}
void stars(int n)
{
String st = new String();
for(int i = 0; i < n; i++)
{
System.out.println(st+="*");
}
for(int i = 1; i < n; i++)
{
System.out.println(st.substring(i, n));
}
}
public class Test
{
public static void main(String[] args)
{
System.out.println(">");
System.out.println(Lines(9));
System.out.println("-");
System.out.println(Amount(5));
System.out.println("<");
}
public static String Lines(int lines)
{
String str = new String();
lines |= 1;
for (int i = 0; i < lines; i++)
{
if (i > 0)
{
str += "\n";
}
for (int j = 0; j < ((i > lines / 2) ? lines - i : i + 1); j++)
{
str += "*";
}
}
return str;
}
public static String Amount(int amount)
{
return Lines((amount & ~1) * 2 + 1);
}
}