Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. package box;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class RecBox {
  6.  
  7. public static void main(String[] args) {
  8. int x,y,z,length,width;
  9.  
  10. x=0; // X is for the horizontal value
  11. y=0; // Y is vertical
  12.  
  13. // Like the Cartesian plane
  14.  
  15. Scanner input = new Scanner(System.in);
  16.  
  17. System.out.println("What is the Width");
  18. width = input.nextInt();
  19.  
  20. System.out.println("What is the Length");
  21. length = input.nextInt();
  22. while(y<length){ //While the y value is not completed, So while the height isin't full.
  23.  
  24.  
  25. while(x<width){ // This just prints out stars until the x vaule is the same as the inputed value
  26. System.out.print("*"); //Printing out stars
  27. x++; // Telling the computer a star has been printed
  28. }System.out.print("\n"); //Adding a new line for the y
  29. x=0; // Making the loop above print again for the new line
  30. y++; // Telling the computer that we need another line
  31.  
  32.  
  33. }
  34.  
  35. }
  36.  
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement