You are on page 1of 3

Green University of Bangladesh

Department of Computer Science and Engineering

Assignment
CSE 201: Object Oriented Programming

Submitted by:
Name Md. Shazzad Hossain Sharif

Student ID 213002258

Section D4

Date of 02-11-2022
Submission

Submitted to:
Mr. Amit Mondol
Lecturer
CSE, Green University of Bangladesh
Source Code:

package assignment;

import java.util.Scanner;

interface CustomizedInterface
{
public int factorSum(int n);
}
class Myfactor implements CustomizedInterface
{
@Override
public int factorSum(int n)
{
int sum=0;
System.out.print("Devisor of "+n+" is ");
for(int i=1;i<=n;i++)
{
if(n%i==0)
{
sum=sum+i;
System.out.print(+i+" ");
}

}
System.out.println();
return sum;

}
}
public class Assignment {

public static void main(String[] args) {


Myfactor ob=new Myfactor();
Scanner sc=new Scanner(System.in);
int n;
do
{
System.out.println("Enter a Number");
n=sc.nextInt();
}
while(n>1000);

System.out.println("Factor of "+n+" sum is "+ob.factorSum(n));


}

Output: (Screenshot)

The End

You might also like