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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!