Hi all, Im new to the site and to Java. Im having some trouble with my current assignment. I was suposed to make an isosceles triangle with asterisks based on a number entered by user. I got the first half correct but I can not figure out my loops for the second half. Do I have to start a new main to get it to descend? Here is what I have done so far. It compiles fine but will not run the descending half of pyramid. Im not sure it makes a difference but I use JCreator for IDE.
Thanks for any assistance.
import java.util.*;
public class homeWork6
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter an interger from 1 to 50:");
int number = keyboard.nextInt();
System.out.println();
if (number < 1)
System.out.println("Invalid number: must be at least one.");
else if (number > 50)
System.out.println("Invalid number: cannot exceed 50.");
else // valid input print triangle of asterisks
{
// print first half
int lineCount;
int asteriskCount;
for (lineCount = 1; lineCount <= number; lineCount++)
{
for (asteriskCount = 1; asteriskCount <= lineCount;
asteriskCount ++)
{
System.out.print("*");
}//end inner for loop
System.out.println();
}//end outer for loop
for (lineCount = 1; lineCount >= number; lineCount --)
{
for (asteriskCount = number; asteriskCount >= lineCount;
asteriskCount --)
System.out.print("*");
}
System.out.println();
} //end else
}//end main
}//end class