// Solution to Project 9.8 import java.util.Scanner; public class PascalTriangle{ public static void main (String[] args){ Scanner reader = new Scanner(System.in); String query = "y"; while (query.equalsIgnoreCase("y")){ System.out.print("Enter the number rows: "); int rows = reader.nextInt(); if (rows <= 10){ int triangle[][] = makePascalTriangle(rows); displayList(triangle); } else System.out.println("Number of rows cannot exceed " + 10); reader.nextLine(); System.out.print("Run again[y/n]? "); query = reader.nextLine(); } } private static void displayList(int a[][]){ int maxCols = a[0].length; String value; for (int row = 0; row < a.length; row++) for (int col = 0; col < maxCols; col++){ if (a[row][col] == 0) value = " "; else value = "" + a[row][col]; System.out.print(String.format("%3s", value) + " "); if (col == maxCols - 1) System.out.println(""); } } // Complete this section: private static int [][] makePascalTriangle(int rows){ // Compute width of array // Create array object // Set all cells to 0 // Set 1 in first row // Set remaining values } }