In: Computer Science
can you assist me in getting the desired output?
Homework 5-3
Write a Java program that prompts the user for an int n. You can assume that 1 ≤ n ≤ 9. You program should use two embedded for loops that produce the following output:
    1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
.
.
.
This is the code:
import java.util.Scanner;
public class PatternOne {
   public static void main(String[] args) {
       // TODO Auto-generated method
stub
Scanner scnr = new Scanner(System.in);
  
//Taking rows value from the user
System.out.println("Please enter a number 1...9 ");
int rows = scnr.nextInt();
System.out.println(" ");
for (int i = 1; i <= 9; i++)
{
for (int j = 1; j <= i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}  
      
   }
      
}

Sir, Please check the screenshot. The code works perfectly as
you want.. please elaborate your issue in comments so that i can
help..
You can re-check the code below:
import java.util.Scanner;
public class PatternOne {
        public static void main(String[] args) {
                Scanner scnr = new Scanner(System.in);
                System.out.println("Please enter a number 1...9 ");
                int rows = scnr.nextInt();
                System.out.println(" ");
                for (int i = 1; i <= 9; i++) {
                        for (int j = 1; j <= i; j++) {
                                System.out.print(j + " ");
                        }
                        System.out.println();
                }
        }
}
************************************************** Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.
Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.