#1 Super Easy Star Reverse Hill Program
- Categories Java
Write a Star Reverse Hill pattern Java program as shown, where no of rows is given by user.
* * * * * * * * *
* * * * * * *
* * * * *
* * *
*
import java.util.Scanner;
public class StarRe Hill { public static void main(String args[]) { Scanner scan = new Scanner(System.in);
System.out.print("Enter Number of Rows : ");
int n = scan.nextInt();
for (int i = 1; i<=n ; i++) {
for (int j = 1; j<=i; j++) { // increasing
System.out.print(“ ”);
}
for (int j = i; j< n; j++) { // decreasing
System.out.print(“* ”);
}
for (int j = i; j<=n; j++) { // decreasing
System.out.print(“* ”);
}
System.out.println();
} } }
You may also like
Single Linked List Programs in Java
28 August, 2021
Implementing Stack using Array in Java
28 August, 2021
Constructor Programs
3 July, 2021