Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class hw6 {
- public static void main(String[] args) {
- int num = 0;
- Scanner s = new Scanner(System.in);
- System.out.println("Please enter a number");
- num = s.nextInt();// getting number from user
- for (int i = num, k = 1; i > 0; i -= 1, num -= 1, k += 1) {// loop for the rows
- for (int j = 0; j < num; j += 1) {// loop for the columns
- System.out.print("*");// prints *
- }
- System.out.println();// next line
- for (int j = 0; j < k; j++) {// loop for spaces
- System.out.print(" ");// prints spaces
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment