Computer HW 2
Computer HW 2
import java.util.*;
class cal
{
public static void main(int n)
{
int i,s=0;
for(i=1;i<n;i++)
if (n%i==0)
}
s=s+I;
{
if (s>n)
System.out.println(“abundant no)”;
else
System.out.pritln(“not a no”);
}
}
--------------------------------------------------------------------------------------------
----
Q2 WAP to input a 5 digit no and print the prime digits of the no.
--------------------------------------------------------------------------------------
Q3. Wap to input a no between 6 to 9 digits and display the absolute
difference between the sum of odd and even digits
import java.util.*;
class cal
{
public static void main()
{
Scanner sc=newScanner(System.in);
Sopln(“enter a no between 6 to 9 digits”);
n=sc.nextInt();
{
int r,oddsum=0,evensum=0,
while(n>0)
r=n%10;
if (r%2==0)
evensum+=r;
else
oddsum+=r;
n=n/10;
}
int differ=Math.abs(oddsum-evensum);
Sopln(differ);
}
}
--------------------------------------------------------------------------------------------
---------------------
Q4.
--------------------------------------------------------------------------------------------
-------------------
Q5. XYLEM NO
import java.util.*;
class cal
{
public static void main()
{
Scanner sc=new Scanner(System.in);
Sopln(“enter a no”);
n=sc.nextInt();
int id=n%10;
n=n/10;
int mean=0;
while(n>9)
{
int r=n%10;