dimanche 14 mai 2017

Nested Loop in Java, output

Hi guys I need help with some code issue. I have to write a program that displays a Star Pattern in a table format. I need help, I am not exactly looking for the exact code, I would like to figure it out myself, so any suggestions and tips would be great.

Picture of Table

 //Pattern A Loop
      for(int PatternA = 0; PatternA <= 9; PatternA++) { //outerLoop Pattern A
      for(int PatternAI = 0; PatternAI <=PatternA;PatternAI++){ //Inner Loop
          System.out.print("+");
          }
          System.out.println();
          }


    //Pattern B Loop
  for(int PatternB = 0; PatternB <=10; PatternB++){ //outer loop Pattern B
      for(int PatternBI = 9; PatternBI >= PatternB; PatternBI--){ //Inner Loop
          System.out.print("+");
          }  
          System.out.println();
          }      

Aucun commentaire:

Enregistrer un commentaire