Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. import java.io.*; import java.util.*;
  2. public class Pyramid{
  3. public static void Pyramid(){
  4. Scanner kbReader = new Scanner(System.in);
  5. System.out.println();
  6. System.out.print("pyramid word - ");
  7. String PyramidWord = kbReader.nextLine( );
  8. System.out.print("number of lines to print (whole number) - ");
  9. int lines = kbReader.nextInt() + 1;
  10. int incr = 1;
  11. String a = PyramidWord + " ";
  12. int alength = a.length();
  13. int StringLength = PyramidWord.length();
  14. int line = 0;
  15. int linelength = lines;
  16. int freespaces = -1;
  17. int spaces = freespaces;
  18. int detspaces = spaces;
  19. System.out.println();
  20. while (line <= lines){
  21. while (freespaces >=0){
  22. System.out.print(" ");
  23. freespaces -= 1;
  24. }
  25. detspaces += alength/2;
  26. spaces = detspaces;
  27. while (spaces >= -1){
  28. System.out.print(" ");
  29. spaces -= 1;
  30. }
  31. linelength -= 1;
  32. incr = 1;
  33. while (incr <= linelength){
  34. System.out.print(a);
  35. incr += 1;
  36. }
  37. System.out.println();
  38. line += 1;
  39. }
  40.  
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement