I hope this helps:
CODE
import java.util.Scanner;
//Declare your class here
public class Runner {
//Create the class to create each iteration of height
public static void print(int height){
//Set the INTEGER "a" set to the value of "height".
int a = height;
/************************************
**Start LOOP
**Start of by setting "lines" = 0
**As log as lines is smaller then a keep looping
**Once the loop is started, increase the value of "lines" for each iteration
**Also you need to decrese the value of "height", meaning the 1st level is
**done so when it starts again it will start at the next level
**This is where you get the AABBAA, which is the "HORIZIONAL" height.
**Meaning level 1 is AA, 2 is AABB, 3 is AABBAA, and so on.
**Once "lines" is equal to "a", stop looping
************************************/
for (int lines = 0; lines < a; lines++, height--){
//If the instance is on an even, then print out "BB"
if(height%2 == 0){
System.out.print("BB");
}
//If the instance is on an odd, then print out "AA"
else if(height%2 == 1){
System.out.print("AA");
}
}
}
//main class, a MUST to run a JAVA App
public static void main(String[] args)
{
//Declare local variables
int a, b, lines, height;
//Set up main to recieve the users inputed data
Scanner sc = new Scanner(System.in);
//Message printed out to user giving directions on what to do
System.out.print("Enter height of the pattern: ");
//assigns the int a to height and then points to the value recieved from the user
a = height = sc.nextInt();
/*****************************************
**loop for each level
**This is where the "VERTICAL" height is applied.
**Example
**AA
**AABB
**AABBAA
**And so on
******************************************/
for(int i=0; i<height; i++){
print(i+1);
System.out.println();
}
}
}