source file name: Div5allDemo.java

import java.io.*;

class A

{

int y;

public A(int n)

{

y=n;

}

public void disp()

{

int d=1;

while(d<=y)

{

if(d%5==0)

System.out.println(d);

d++;

}

}

}

class Div5allDemo

{

public static void main(String as[])

int n=1;

System.out.println("enter value: ");

try

{

DataInputStream dis=new DataInputStream(System.in);

String s=dis.readLine();

n=Integer.parseInt(s);

}

catch(Exception e)

{

System.out.println(e);

}

A ob=new A(n);

System.out.println("divisible by 5 : ");

ob.disp();

}

}


output:

D:\JavaPrograms\Constructors>javac Div5allDemo.java

D:\JavaPrograms\Constructors>java Div5allDemo
enter value:
62
divisible by 5 :
5
10
15
20
25
30
35
40
45
50
55
60