-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathractangle1.java
More file actions
39 lines (31 loc) · 1.08 KB
/
ractangle1.java
File metadata and controls
39 lines (31 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// import java.util.Scanner;
// public class ractangle1 {
// public static void main(String[] args) {
// Scanner sc = new Scanner (System.in);
// int r =sc.nextInt();
// int c = sc.nextInt();
// for(int i = 1; i <= r; i++){
// for(int j = 1; i<=c; j++){
// System.out.print("*");
// }
// System.out.println();
// }
// }
// }
import java.util.Scanner;
public class ractangle1 { // Class name should follow CamelCase convention
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the number of rows (height): ");
int rows = sc.nextInt();
System.out.print("Enter the number of columns (width): ");
int cols = sc.nextInt();
for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= cols; j++) {
System.out.print("*");
}
System.out.println(); // Newline after each row
}
System.out.println(); // Newline after the rectangle
}
}