0% found this document useful (0 votes)
5 views2 pages

Java Program for Composite Numbers & Digit Sum

Uploaded by

geeta
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Java Program for Composite Numbers & Digit Sum

Uploaded by

geeta
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

import [Link].

Scanner;

class Main {
public static void main(String[] args) {
int choice;
Scanner sc=new Scanner([Link]);

[Link]("1 to find composite no ");


[Link]("2 to find sum of digit ");
[Link]("enter your choice ");
choice=[Link]();
switch(choice)
{
case 1:
int no ,count=0;
[Link]("enter no");
no=[Link]();
for(int i=2;i<no;i++)
{
if(no%i==0)
{
count++;
}

}
if(count>2)
{
[Link]("It is a composite no");

}
{
[Link]("It is not a composite no");

}
break;
case 2:
int number,sum=0;
[Link]("enter no");
number=[Link]();
while(number>0)
{
int rem=number%10;
sum=sum+rem;
number=number/10;
}
[Link]("sum of digit is"+sum );
break;
default:
[Link]("Incorrect choice" );
}

}
}

You might also like