Question: import java.io.*; import java.util.Scanner; public class NumberPattern{ public static void printTriangle(int n){ int a = 2*n - 1; for (int i=0; i
import java.io.*; import java.util.Scanner; public class NumberPattern{ public static void printTriangle(int n){ int a = 2*n - 1; for (int i=0; i public static void main(String args[]){ Scanner sc = new Scanner(System.in); System.out.println("Enter the number of rows:"); int n = sc.nextInt(); sc.close(); printTriangle(n); } } Whenever I go to run this on BlueJ (Java programming), the spacing is a little off. The triangle seems to slope a little bit to the right and I cannot figure out how to make it into a symmetrical triangle. I am not sure if it is a spacing issue or what. If someone could figure it out that would be great. Thank you very much.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
