Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package box;
- import java.util.Scanner;
- public class RecBox {
- public static void main(String[] args) {
- int x,y,z,length,width;
- x=0; // X is for the horizontal value
- y=0; // Y is vertical
- // Like the Cartesian plane
- Scanner input = new Scanner(System.in);
- System.out.println("What is the Width");
- width = input.nextInt();
- System.out.println("What is the Length");
- length = input.nextInt();
- while(y<length){ //While the y value is not completed, So while the height isin't full.
- while(x<width){ // This just prints out stars until the x vaule is the same as the inputed value
- System.out.print("*"); //Printing out stars
- x++; // Telling the computer a star has been printed
- }System.out.print("\n"); //Adding a new line for the y
- x=0; // Making the loop above print again for the new line
- y++; // Telling the computer that we need another line
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement