0% found this document useful (0 votes)
20 views4 pages

Different Numbers in Java

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)
20 views4 pages

Different Numbers in Java

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/ 4

Q1.

A spy number is a number where the sum of its digits equals the product of its
digits. For example, 1124 is a spy number, the sum of its digits is 1+1+2+4=8 and the
product of its digits is 1*1*2*4=8

Q2. A number is called Disarium number if the sum of its power of the positions from
left to right is equal to the number. Example: 1 + 3*3 + 5*5*5 = 1 + 9 + 125 = 135

Q3. A tech number can be tech number if its digits are even and the number of digits
split into two number from middle then add these number if the added number’s
square would be the same with the number it will called a Tech Number. If the number
is split in two equal halves, then the square of sum of these halves is equal to the
number itself. Write a program to generate and print all four digits tech numbers. Note:
If number of digits is not even then it is not a tech number.

Q4. A number is said to be an Ugly number if positive numbers whose prime factors
only include 2, 3, 5. For example, 6(2×3), 8(2x2x2), 15(3×5) are ugly numbers while
14(2×7) is not ugly since it includes another prime factor 7. Note that 1 is typically
treated as an ugly number.

Q5. If the sum of the digits is equal to the sum of the prime factors of the number is
called as Smith number.
Example: 378 Sum of the digits 3+7+8=18
Sum of the prime factors 2+3+3+3+7=18

Q6. Increasing number: If digits of a number is in ascending order called Increasing


number. Ex. 23456

Q7. Decreasing number: If digits of a number is in descending order called Decreasing


number. 87530

Q8. Bouncy number: If the digits of a number is neither increasing nor decreasing called
Bouncy number: 185349

Q9. Write a program to input an integer and check whether it is a Special Number or
NOT. (Sum of the factorial of each digits when it is equal to the number called Special
number. ex. 145)

Q10. Write a program to input an integer and for a new number arranging it’s digits in
ascending order.
Q11. WAP to input an integer and for a new number arranging it’s digits in descending
order.

Q12. WAP to input an integer and check whether it is a Magic number or NOT. (Sum of
the digits when recursively added till become single digit and if it is 1 called Magic
number.)

Q13. WAP to input 10 integers and check all the numbers are Trimorphic numbers or
NOT. (Trimorphic number is found end of it’s cube. Ex. 253=15625)

Q14. WAP to input an integer and convert it in Decimal number or in Binary number
according to the user’s choice. (Using switch case)

Q15. WAP to input an integer and check whether it is an Evil number. (The Evil number is
another special positive whole number in Java that has an even number of 1's in its binary
equivalent. Ex.12‐> 1100)

Q16. Bank announces a new tariffs in Term deposit Schemes for their customers and Senior
Citizenship accordingly:
Term Rate of Interest (General) Rate of interest (Senior citizen)
Upto 1 year 7.5% 8.0%
More than 1 to 2 years 8.5 9.0
More than 2 to 3 years 9.5 10.0
More than 3 years 10.0 11.0

The Senior citizen is applicable to those customers whose age is 60 years or more. WAP to
accept the term in term of deposit scheme, age of the customer and the sum assured.
The program displays the information in the given format:
Sum assured Term Age Interest earned Amount paid
xxx xxx xxx xxx xxx
System.out.println(“Sum assured/tTerm/tAge/tInterest earned/tAmount paid”);
System.out.println(sum+”/t”+term+”/t”+age+”/t”+iner+”/t”+(sum+iner));

Q17. WAP to input a number and find the positive difference between Increment and
Decreament numbers.
Sample input:52019
Ascending order:1259
Descending order:95210
Difference: 93915

Q18. WAP to input an integer and check whether it is a Circular Prime number or NOT.
A circular prime is a prime number with the property that the number generated
at each intermediate step when cyclically permuting its digits will be prime. For
example, 1193 is a circular prime, since 1931, 9311 and 3119 all are also prime.
1193 3119 9311 1931
import java.util.Scanner;

class CircularPrime
{
public static void main()
{

int n, num, r, c = 0, flag = 0;


Scanner sc = new Scanner(System.in);
System.out.print("Enter number=");
n = sc.nextInt();
num = n;
while (num > 0)
{
r = num % 10;
c++;
num = num / 10;
}
num = n;//1193
for (int i = 1; i <= c; i++)
{
r = num % 10;//1
num = num / 10;//193
num = (r * (int) Math.pow(10, c ‐ 1)) + num;//1193
int f=0;
for(int j=1;j<=num;j++)
{
if (num % j == 0)
{
f++;
}
}
if(f>2)
{
flag = 1;
break;
}
}
if(flag==0)
{
System.out.println("Circular Prime");
}
else
{
System.out.println("Not Circular Prime");
}

}
}

Write the following switch‐case construct in single if statement


switch(ch)
{
case 1:
System.out.println(“Be good”);
break;
case 2:
System.out.println(“Be good”);
break;
}
if(ch==1 || ch==2)

Q19. The amicable numbers are two different numbers (a pair of numbers) so related that the sum of
the proper divisors (excluding the number itself) of one of the numbers is equal to the other. A proper
divisor of a number is a divisor other than the number itself. It is also known as friendly numbers.
pair of amicable numbers is (220, 284)
The divisor of 220 are: 1,2,4,5,10,11,20,22,44,55,and 110
The sum of divisor of 220 is = 284
The divisor of 284 are: 1,2,4,71,142
The sum of divisor of 284 is = 220
WAP to input two integers and check whether they are Amicable numbers or NOT.

Q20. Write a menu driven program to print the following Patterns:‐


Pattern 1: ##### Pattern 2: 9
##### 79
##### 579
##### 3579
##### 13579

Q21. The happy number can be defined as a number which will yield 1 when it is replaced
by the sum of the square of its digits repeatedly. Example: 32 is a Happy number.
32+22=12 +32=12+02=1
WAP to input an integer and check whether it is a Happy number or NOT.

You might also like