Untitled
CODEWITHKARANTIGER
plain_text
a month ago
972 B
1
Indexable
Never
package pattern; class fullbutterfly{ public static void main(String[] args) { int n = 4; int spaces = (2 * n) - 2; int stars = 1; int currentline = 1; while (currentline <= n) { // print stars for (int i = 1; i <= stars; i++) { System.out.print("* "); } //print spaces for (int i = 1; i <= spaces; i++) { System.out.print(" "); } //print stars for (int i = 1; i <= stars; i++) { System.out.print("* "); } // prepare for next line System.out.println(); if (currentline<n) { stars++; spaces = spaces - 2; } else { stars--; spaces = spaces+1; } currentline++; } } }
Leave a Comment