Exercise SquareBoard (nested-loop) ~ Programming is Fun
 Programming is Fun!

www.anandsingh.net
Subscribe For Free Updates!

We'll not spam mate! We promise.

Friday, September 12, 2014

Exercise SquareBoard (nested-loop)

Write a program called SquareBoard that displays the following n×n (n=5) pattern using two nested for-loops.
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
Your program should use only two output statements, one EACH of the followings:
System.out.print("# ");   // print # and a space, without newline
System.out.println();     // print a newline
Hints:
public class SquareBoard {   // saved as "SquareBoard.java"
   public static void main (String[] args) {
      int size = 5;    // size of the board
      for (int row = 1; ......; ......) {
         for (int col = 1; ......; ......) {
            ......
         }
         ......
      }
   }
}


Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →

0 comments:

Post a Comment