/* Maryam Shaheen #1140427 */ public class Task_1 { // the First Task (Display numbers in a pyramid pattern using for nested loops ) public static void main (String[] args) { int line,j,k,L; // defining variables for ( line = 0; line < 8; line++) { // A loop for number of lines for ( L = 8 - line; L > 0; L--) { // A loop for printing spaces System.out.print(" "); // space printing statement } for (j = 0; j <= line; j++) { // A loop for the left side of the pyramid System.out.printf("%3d ", 1 << j); // printing statement to print the left side numbers } for ( k = line - 1; k >= 0; k--) { // A loop for the right side of the pyramid System.out.printf("%3d ", 1 << k); //printing statement to print the right side numbers } System.out.println(); //printing statement to print new line } } }