Advertisement
202revenge

Triangle.java

Oct 24th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. /*
  2. *File name: Triangle.java
  3. *
  4. *Programmer: Derek Townsend
  5. *ULID: djtown1
  6. *
  7. *Date: Oct 23, 2017
  8. *
  9. *Class: IT 168
  10. *Lecture Section: 004
  11. *Lecture Instructor:Dr Xing Fang
  12. *Lab Section: 005
  13. *Lab Instructor: Simran Kaur
  14. */
  15. package edu.ilstu;
  16.  
  17. import java.util.Scanner;
  18.  
  19. /*
  20. *<insert description>
  21. *
  22. * @author Derek
  23. *
  24. */
  25. public class Triangle
  26. {
  27.  
  28.  
  29. public static void main(String[] args)
  30. {
  31. String star="";
  32. Scanner keyboard = new Scanner(System.in);
  33. System.out.println("Enter the size of a triangle from 1 to 50");
  34. int size=keyboard.nextInt();
  35.  
  36.  
  37. for(int i = 0;i<size;i++) {
  38. star+="*";
  39. System.out.println(star);
  40.  
  41.  
  42. }
  43.  
  44. for(int j = 0;j<size;j++) {
  45. star=star.substring(0, star.length()-1);
  46. System.out.println(star);
  47.  
  48. }
  49.  
  50.  
  51. keyboard.close();
  52.  
  53. }
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement