package BasicJava;
import java.util.Scanner;
public class PatternMyselfPractise {
public static void main(String[] args) {
/*SampleOutput:
* *
** **
*** ***
**** ****
**********
*/
Scanner input = new Scanner(System.in);
int a,b,c;
System.out.println("How many lines:");
a = input.nextInt();
b = a;
for (int i = 1; i <= a; i++) {
for (int j = 1; j <= i; j++) {
System.out.print("*");
}
for (int k =1 ; k <= 2*(b-1); k++) {
System.out.print(" ");
}
for (int l = 1; l <= i; l++) {
System.out.print("*");
}
b--;
System.out.println("");
}
}
}
Comments
Post a Comment