# Java Number Programs (ISC Classes 11 / 12)

## Java Iterative Stmts

Write a program in Java to accept a number. Check and print whether it is a prime number or not.

A prime number is a number which is divisible by 1 and itself only. For example 2, 3, 5, 7, 11, 13 are all prime numbers.

View Answer84 Likes

## Java Iterative Stmts

Write a menu driven program to accept a number from the user and check whether it is a Prime number or an Automorphic number.

(a) Prime number: (A number is said to be prime, if it is only divisible by 1 and itself)

Example: 3,5,7,11

(b) Automorphic number: (Automorphic number is the number which is contained in the last digit(s) of its square.)

Example: 25 is an Automorphic number as its square is 625 and 25 is present as the last two digits.

View Answer142 Likes

## User Defined Methods

A Prime-Adam integer is a positive integer (without leading zeros) which is a prime as well as an Adam number.

Prime number: A number which has only two factors, i.e. 1 and the number itself.

Example: 2, 3, 5, 7 … etc.

Adam number: The square of a number and the square of its reverse are reverse to each other.

Example: If n = 13 and reverse of 'n' = 31, then,

(13)

^{2}= 169(31)

^{2}= 961 which is reverse of 169thus 13, is an Adam number.

Accept two positive integers m and n, where m is less than n as user input. Display all Prime-Adam integers that are in the range between m and n (both inclusive) and output them along with the frequency, in the format given below:

Test your program with the following data and some random data:

Example 1

INPUT:

m = 5

n = 100OUTPUT:

THE PRIME-ADAM INTEGERS ARE:

11 13 31

FREQUENCY OF PRIME-ADAM INTEGERS IS: 3Example 2

INPUT:

m = 100

n = 200OUTPUT:

THE PRIME-ADAM INTEGERS ARE:

101 103 113

FREQUENCY OF PRIME-ADAM INTEGERS IS: 3Example 3

INPUT:

m = 50

n = 70OUTPUT:

THE PRIME-ADAM INTEGERS ARE:

NIL

FREQUENCY OF PRIME-ADAM INTEGERS IS: 0Example 4

INPUT:

m = 700

n = 450OUTPUT:

INVALID INPUTView Answer44 Likes

## Java Iterative Stmts

Write a program to input a number and check and print whether it is a Pronic number or not. [Pronic number is the number which is the product of two consecutive integers.]

Examples:

12 = 3 * 4

20 = 4 * 5

42 = 6 * 7View Answer202 Likes

## Java Iterative Stmts

An Abundant number is a number for which the sum of its proper factors is greater than the number itself. Write a program to input a number and check and print whether it is an Abundant number or not.

Example:

Consider the number 12.

Factors of 12 = 1, 2, 3, 4, 6 Sum of factors = 1 + 2 + 3 + 4 + 6 = 16

As 16 > 12 so 12 is an Abundant number.

View Answer67 Likes

## Java Iterative Stmts

Write a program to input a number. Check and display whether it is a Niven number or not. (A number is said to be Niven which is divisible by the sum of its digits).

Example: Sample Input 126

Sum of its digits = 1 + 2 + 6 = 9 and 126 is divisible by 9.View Answer208 Likes

## Java Iterative Stmts

Write a program to accept a number and check whether it is a 'Spy Number' or not. (A number is spy if the sum of its digits equals the product of its digits.)

Example: Sample Input: 1124

Sum of the digits = 1 + 1 + 2 + 4 = 8

Product of the digits = 1*1*2*4 = 8View Answer163 Likes

## Java Iterative Stmts

A special two-digit number is such that when the sum of its digits is added to the product of its digits, the result is equal to the original two-digit number.

Example: Consider the number 59.

Sum of digits = 5 + 9 = 14

Product of digits = 5 * 9 = 45

Sum of the sum of digits and product of digits = 14 + 45 = 59Write a program to accept a two-digit number. Add the sum of its digits to the product of its digits. If the value is equal to the number input, then display the message "Special two—digit number" otherwise, display the message "Not a special two-digit number".

View Answer222 Likes

## Java Iterative Stmts

A prime number is said to be 'Twisted Prime', if the new number obtained after reversing the digits is also a prime number. Write a program to accept a number and check whether the number is 'Twisted Prime' or not.

Sample Input: 167

Sample Output: 761

167 is a 'Twisted Prime'.View Answer93 Likes

## Java Iterative Stmts

Write a program to enter two numbers and check whether they are co-prime or not.

[Two numbers are said to be co-prime, if their HCF is 1 (one).]

Sample Input: 14, 15

Sample Output: They are co-prime.View Answer123 Likes

Showing 11 - 20 of 29 Questions