Java
UNIT CHALLENGES

separator-blank.png

ALTERNATIVE AP CHALLENGE


separator-blank.png

CHALLENGE 1 – STAR BUTTERFLY

Write a program that uses nested for loops to output a butterfly shape as shown below.  The program should ask the user to provide the number of rows.  If the provided number is even, you should double up the middle row.

Note that each wing is its own triangle.  So rows will have 0, 2, 4, 6, … spaces in them.

Sample output 1

 

     How many rows?

     7

 

     *      *

     **    **

     ***  ***

     ********

     ***  ***

     **    **

     *      *

 

Sample output 2

 

     How many rows?

     6

 

     *    *

     **  **

     ******

     ******

     **  **

     *    *

 

EXTRA CRITERIA (TO GET 100%)

 

None

 

separator-campeau.png