1. import java.util.Scanner;
  2. 
  3. /**
  4. * Lab1.java
  5. * @author Jose M Vidal <jmvidal@gmail.com>
  6. * Created on Jan 30, 2012
  7. *
  8. */
  9. 
  10. public class Lab1 {
  11. 
  12. /**
  13. * @param args
  14. */
  15. public static void main(String[] args) {
  16. Scanner keyboard = new Scanner(System.in);
  17. System.out.print("Enter base width: ");
  18. int width = keyboard.nextInt();
  19. for (int row = 0; row <= width / 2; row++) {
  20. for (int col = 0; col <= width; col++) {
  21. if (Math.abs((width / 2) - col) <= row)
  22. System.out.print("*");
  23. else
  24. System.out.print(" ");
  25. }
  26. System.out.println("");
  27. }
  28. }
  29. 
  30. }