I am having difficulty regarding the 1 problem even though i m getting the output as the sample shown. My submission is showing an error.
Please help me solve the error.
This is the question:
Print the First 3 multiples of the given number "N". (N is a positive integer)
Note: print the characters with a single space between them.
Input Description:
A positive integer is provided to you as an input.
Output Description:
Print the First 3 multiples of the number with single spaces between them as an output.
Sample Input :
2
Sample Output :
2 4 6
This is the code i have provided :
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner obj = new Scanner(System.in);
int userInput = obj.nextInt();
//System.out.println("The Input Provided is: " + userInput);
int num;
if(userInput > 0)
{
for (int i =1; i < 4; i++)
{
num = userInput * i ;
System.out.print(num + " ");
}
}
}
}