Ads

HOW TO PRINT STAR IN JAVA LANGUAGE | JAVA PROGRAMMING | STAR DRAWING IN JAVA

 public class star{

public static void main(String[]args){

int s=29, p=1, p2=0, p3=30, p4=0, p5=20,s2=0;

for(int a=1; a<=30; a++){

for(int b=1; b<=s; b++){

if(a>9 & b==p4){

System.out.print("_");

}

else {

if (a==10 & b>=1) {

System.out.print("_");

}

else {

System.out.print(" ");

}

}

}

if (a==1) {

System.out.print("_");

}

for(int c=1; c<=p; c++) {

if(c==1^c==p^c==p2^c==p3) {

System.out.print("_");

}

else {

if(a==10){

System.out.print("_");

}

else {

System.out.print(" ");

}

}

}

if (a>9) {

p4=p4+2;

}

if (a>15) {

p2=p2+4;

p3=p3-2;

}

s=s-1;

p=p+2;

if(a>9 & a<18) {

for(int e=1; e<=p5; e++) {

if(e==p5) {

System.out.print("_");

}

else {

if (a==10) {

System.out.print("_");

}

else {

System.out.print(" ");

}

}

}

p5=p5-3;

s2=s2+1;

}

System.out.println();

}

}

}

Post a Comment

0 Comments