Subject:
Computer ScienceAuthor:
leticiamcknightCreated:
1 year agoAnswer: class composite{
static void check(int a)//a is the number to be checked
{int n=0;//n is number of a’s factors
for(int i=1;i<=a;i++){
if(a%i==0)
n++;}
if(n>2)
System.out.println(a+” is a composite number”);
else
System.out.println(a+” is a prime number”);
}}
Author:
raymacias
Rate an answer:
19Answer:
1-To check and display whether a number input by the user is a composite number or not.
A number is said to be composite, if it has one or more than one factors excluding 1 and the number itself.
Example: 4, 6, 8, 9…
2-To find the smallest digit of an integer that is input:
Sample input: 6524
Sample output: Smallest digit is 2
For an incorrect choice, an appropriate error message should be displayed.
Author:
teófanessherman
Rate an answer:
7