Question: Can someone check my Java code please? For some reason my output keeps looking like [see image] Why does the first * keep jarring to

Can someone check my Java code please?

For some reason my output keeps looking like [see image]

Why does the first * keep jarring to the right? Please help, how do I get it to line up? Code is below, thank you.

Can someone check my Java code please? For some reason my output

import java.util.*;

public class Recursion

{

public static void getPins(int numRows, int totalRows)

{

if(numRows == 1)

{

System.out.print("\t\t");

for(int i = 1; i

System.out.print(" ");

System.out.println("*");

}

else

{

System.out.print("\t\t");

getPins(numRows - 1, totalRows);

for(int i = 1; i

System.out.print(" ");

for(int i = 1; i

System.out.print("* ");

System.out.println();

}

}

@SuppressWarnings("resource")

public static void main(String args[])

{

Scanner scan = new Scanner(System.in);

System.out.print("Enter number of rows of pins to set up:");

int num = scan.nextInt();

getPins(num, num);

}

}

__________________________

I want it to look like...

keeps looking like [see image] Why does the first * keep jarring

Console X Recursion [Java Application] CUsers Admin DesktopJava Enter number of rows of pins to set up:3

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!