Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2015
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Exercise4v2 {
  4. public static void main(String [] args) {
  5. Scanner feed = new Scanner(System.in);
  6.  
  7. // Asks user for dimensions of square
  8. System.out.println("Input desired height of the square");
  9. int width = feed.nextInt();
  10. int lines = width;
  11.  
  12. do {
  13. for(int a=0; a<width; a++) {
  14. System.out.print("X");
  15. }
  16.  
  17. width=0;
  18. }while(width>0);
  19. width=lines;
  20. System.out.println();
  21. System.out.print("X");
  22. //System.out.println(lines + "lines arvo");
  23. //System.out.print(width + "width arvo");
  24.  
  25. while(lines>2) {
  26.  
  27. do {
  28. for(int a=2; a<width; a++) {
  29. System.out.print(" ");
  30. }
  31. //System.out.print("w="+width);
  32. width--;
  33. }while(width>2);
  34.  
  35. if(width==2) {
  36. System.out.print("X");
  37. System.out.println();
  38.  
  39. }
  40. //System.out.print("w="+width);
  41. System.out.print("l="+lines);
  42. lines--;
  43. }
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement