Java Program to Print the Series 11 22 33 44 55 … N

In the previous article we have discussed about Java Program to print Series 8 6 9 23 87 … N

In this article we are going to see how to print the series 11 22 33 44 55 … N by using Java programming language.

Java Program to Print the Series 11 22 33 44 55 … N

On observing the pattern carefully, we can see

1st number starts from 11, Then the next number is the nth times of the previous number

Example:

11 22 33 44 55 66 N

11*1             11*2            11*3            11*4            11*5             11*6                                 11*n

Let’s see different ways to  print the series 11 22 33 44 55 … N

Method-1: Java Program to Print the Series 11 22 33 44 55 … N By Using For Loop

Approach:

  • Create Scanner class object.
  • Declare an integer variable say ‘n’ which holds the Nth term of the series
  • Prompt the user to enter a number as value of n.
  • Let declare a integer variable say ‘number’ and initialize it to 11
  • Use a for loop from i=1 to i<=n where the loop is incremented by 1
  • Let declare an integer variable say ‘result
  • Inside the for loop we will find the value of result = number*i.
  • Print the result in the series.

Program:

import java.util.*;
public class Main
{
    public static void main(String [] args)
    {
        //creating object of Scanner class 
        Scanner s = new Scanner(System.in);
        //Taking input of number of elements in the series
        System.out.println("Enter the Nth term “N” ");
        int n = s.nextInt();
        int number = 11;
        //for loop to print the series
        for (int i = 1; i <= n; i++) 
        {
            int result = number*i; 
            System.out.print(result+" ");
        } 
    }
}
Output:

Enter the Nth term “N” 
5
11 22 33 44 55

Method-2: Java Program to Print the Series 11 22 33 44 55 … N By Using While Loop

Approach:

  • Create Scanner class object.
  • Declare an integer variable say ‘n’ which holds the Nth term of the series
  • Prompt the user to enter a number as value of n.
  • Let declare a integer variable say ‘number’ and initialize it to 11
  • Declare and initialize an integer variable i=1
  • Continue a while loop till i<=n, where i is incremented by 1.
  • Declare an integer variable ‘result
  • Inside while loop find the value of result = number*i
  • Print the result in the series.

Program:

import java.util.*;
public class Main
{
    public static void main(String [] args)
    {
        //creating object of Scanner class 
        Scanner s = new Scanner(System.in);
        //Taking input of number of elements in the series
        System.out.println("Enter the Nth term “N” ");
        int n = s.nextInt();
        int number=11;
        int i=1;
        while(i<=n)
        {
            int result =number*i; 
            System.out.print(result+"  ");
            i++;
        }      
    }
}
Output:

Enter the Nth term “N” 
7
11 22 33 44 55 66 77

Method-3: Java Program to Print the Series 11 22 33 44 55 … N By Using For Loop

Approach:

  • Create Scanner class object.
  • Declare an integer variable say ‘n’ which holds the Nth term of the series
  • Prompt the user to enter a number as value of n.
  • Call a user defined method printSeries() by passing n as parameter.
  • Inside method declare a integer variable say ‘number’ and initialize it to 11
  • Use a for loop from i=1 to i<=n where the loop is incremented by 1
  • Let declare an integer variable say ‘result
  • Inside the for loop we will find the value of result = number*i.
  • Print the result in the series.

Program:

import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        // creating object of scanner class 
        Scanner s = new Scanner(System.in);
        //Taking input of number of elements in the series
        System.out.println("Enter the value of Nth term 'N' ");
        int n = s.nextInt();
        // calling printSeries method to print the series
        printSeries(n);
    }
    
    //printSeries metthod to print the series
    public static void printSeries(int n)
    {
        int number = 11;
        //for loop to print the series
        for (int i = 1; i <=n; i++) 
        {
            int result =number*i; 
            System.out.print(result+" ");
        } 
    }
}
Output:

Enter the value of Nth term 'N' 
6
11 22 33 44 55 66

Access the Simple Java program for Interview examples with output from our page and impress your interviewer panel with your coding skills.

Related Java Programs:

Leave a Comment