Output Expected:
# # # # # # #
# # # # # # #
# # # # # # #
# # # # # # #
# # # # # # #
# # # # # # #
# # # # # # #
Java Code:
package checkboard;
public class Main {
/**
* Main class will print checkboard pattern
*/
public static void main(String[] args) {
for(int i = 1 ; i <=7 ; i++) {
if(i %2 == 0)
System.out.print(" ");
for(int col = 1 ; col <=7 ; col++)
System.out.print("# ");
System.out.println();
}
}
}
// Hi this one is the first basic exercise to make yourself comfortable in loops
// Java Basics- Practice session- 1
# # # # # # #
# # # # # # #
# # # # # # #
# # # # # # #
# # # # # # #
# # # # # # #
# # # # # # #
Java Code:
package checkboard;
public class Main {
/**
* Main class will print checkboard pattern
*/
public static void main(String[] args) {
for(int i = 1 ; i <=7 ; i++) {
if(i %2 == 0)
System.out.print(" ");
for(int col = 1 ; col <=7 ; col++)
System.out.print("# ");
System.out.println();
}
}
}
// Hi this one is the first basic exercise to make yourself comfortable in loops
// Java Basics- Practice session- 1
No comments:
Post a Comment