Thursday, 13 June 2013

print given number of series in java

import java.io.*;
class simple_print_given_series
{
    public static void main(String args[])
    {
        int start,end;
        try
        {
            DataInputStream cin=new DataInputStream(System.in);
            System.out.println("Enter number from where you want to print series");
            start=Integer.parseInt(cin.readLine());
            System.out.println("Enter number where you want to stop series");
            end=Integer.parseInt(cin.readLine());

            while(start<=end)
            {
                System.out.println(start+"");
                start++;
            }
        }
        catch(Exception e)
        {
            System.out.println("wrong data");
        }
    }
}

No comments: