Monty374

Ex4

Oct 19th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. package chapt7ex4;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Chapt7Ex4 {
  6.  
  7. /**
  8. * @param args the command line arguments
  9. */
  10. public static void main(String[] args) {
  11. addSpaces();
  12. }
  13.  
  14. public static void drawBar(int i) {
  15. for (int k = 1; k <= i + 1; k++) {
  16. System.out.print(" *");
  17. }
  18. System.out.print("\n");
  19. }
  20.  
  21. public static void addSpaces() {
  22. int size;
  23. Scanner input = new Scanner(System.in);
  24. System.out.print("\nEnter width: ");
  25. size = input.nextInt();
  26. for (int i = 0; i < size; i++) {
  27. for (int j = size; j > i; j--) {
  28. System.out.print(" ");
  29. }
  30. drawBar(i);
  31. }
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment