0% found this document useful (0 votes)
3 views

Computer

Uploaded by

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

Computer

Uploaded by

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

Question 1: Define a class to accept a number and check whether it is a

SUPERSPY number or not.


(A number is called SUPRSPY if the sum of the digits equals the number of
the digits.)

import java.util.*;
public class superspy
{
public static void main(String args[])
{
Scanner sc = new Scanner (System.in);
System.out.println(“Enter a number ”);
int n = sc.nextInt();
int a=n;
int rem , s =0;
int count =0;

while (a>0)
{
rem = a%10;
s = s+rem ;
a=a/10;
count++;
}

if (s== count )
{
System.out.println(“super spy number ”);
}
else
{
System.out.println(“Not a super spy number ”);
}}}

You might also like