Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Rectangle {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int width;
- System.out.println("Input width:");
- width = sc.nextInt();
- int height;
- System.out.println("Input height:");
- height = sc.nextInt();
- for (int j = 1; j <= height; j = j + 1) {
- if ((j == 1) | (j == height)) {
- for (int i = 1; i <= width; i++) {
- System.out.print("*");
- }
- }else {
- for (int k = 1; k <= width; k++) {
- if ((k==1) | (k == width)) {
- System.out.print("*");
- }else {
- System.out.print(" ");
- }
- }
- }
- System.out.println();
- }
- }
- }
Add Comment
Please, Sign In to add comment