Skip to content

Instantly share code, notes, and snippets.

@scottfrazer
Created April 18, 2011 17:35
Show Gist options
  • Save scottfrazer/925767 to your computer and use it in GitHub Desktop.
Save scottfrazer/925767 to your computer and use it in GitHub Desktop.
public class CS1_Frazer_X11_1
{
public static void main(String[] args)
{
int x; //the number the user enters for how large the triangle will be.
int y; // the number that determines how many astericks in that row.
System.out.println("Hello, please enter a number from one to fifty.");
Scanner k = new Scanner(System.in);
x = k.nextInt();
int asteriskCount = 0;
if (x > 50 || x < 1)
System.out.println("Error! Invalid entry! Program will now exit n00b.");
for(y=0; y < 2*x-1; y++) {
if ( y < x-1 )
asteriskCount++
for( i = 0; i < asteriskCount; i++) {
System.out.print(asteriskCount);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment