Answer to Question #284845 in Java | JSP | JSF for Adeng

Question #284845

Write a Program that will ask the user to input the

length and width of the rectangle pattern using

“*”.

Enter the length of rectangular pattern: 5

Enter the width of the rectangular pattern: 4

Output:

****

****

****

****

****

Hint: Use Do-while inside a Do-while


1
Expert's answer
2022-01-05T01:40:36-0500
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter the length of rectangular pattern: ");
        int length = in.nextInt();
        System.out.print("Enter the width of the rectangular pattern: ");
        int width = in.nextInt();
        do {
            int widthT = width;
            do {
                System.out.print("*");
            } while (--widthT > 0);
            System.out.println();
        } while (--length > 0);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Adeng
05.01.22, 17:11

Thank you.

Leave a comment

LATEST TUTORIALS
New on Blog