Advertisement
hpilo

Chapter4_Loops_Ex14

Dec 15th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /*
  4. =====================================
  5. chapter 4: Loops
  6.  
  7. Ex14: Carpet
  8. =====================================
  9. */
  10.  
  11. public class MyProgram {
  12. public static void main(String[] args) {
  13.  
  14. //variables
  15. int size;
  16. Scanner s = new Scanner(System.in);
  17.  
  18. //user input
  19. System.out.println("Enter size: ");
  20. size = s.nextInt();
  21.  
  22. //printing carpet
  23. for (int row = 0; row < size; row++){
  24. for (int i = 0; i < size; i++) {
  25. for (int col = 0; col < size; col++) {
  26. for (int j = 0; j < size; j++) {
  27. System.out.print("*");
  28. }
  29. System.out.print(" ");
  30. }
  31. System.out.println();
  32. }
  33. System.out.println();
  34. }
  35.  
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement