Star patterns with Java (along with their flowcharts)

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int s = 1;
        int i = s;
        float h = (n/2);
        for (int r = 2; r <= h; ++r) {
            for (; s < h; ++s) {
                System.out.print("*");
            }
            for (int sp = (i*2); sp != 2; --sp) {
                System.out.print(" ");
            }

            for (s=r; s <= h; ++s) {
                System.out.print("*");
            }
            s = r;
            i = i+1;
            System.out.println();
        }
    }
}
[xyz-ihs snippet="200-x-90"]

[xyz-ihs snippet=”200-x-90″]

Click here to view the stars flowchart

[xyz-ihs snippet=”Google-Adsense”]

Leave a Comment

Kindly solve the following puzzle to prove that you\'re not a bot: