Skip to content

Instantly share code, notes, and snippets.

@Pyroarsonist
Last active September 13, 2015 17:45
Show Gist options
  • Select an option

  • Save Pyroarsonist/d3bb953a54a7e1dc8919 to your computer and use it in GitHub Desktop.

Select an option

Save Pyroarsonist/d3bb953a54a7e1dc8919 to your computer and use it in GitHub Desktop.
Stars
package lvl2cc;
import java.util.Scanner;
public class Main { public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int x=2;
int y=2;
boolean z=false;
System.out.print("Input maximum of stars: ");
int k=sc.nextInt();
k++;
do {
System.out.print("*");
if (x==y&&y<k&&z==false){
System.out.println();
x=1;
y++;
}
if (y==k){
z=true;
}
if (x==y&&y>0&&z==true){
System.out.println();
x=1;
y--;
}
x++;
} while (y!=1);
sc.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment