# Java Number Programs (ICSE Classes 9 / 10)

## User Defined Methods

Write a program to input a number. Use a function int Armstrong(int n) to accept the number. The function returns 1, if the number is Armstrong, otherwise zero(0).

Sample Input: 153

Sample Output: 153 ⇒ 1^{3}+ 5^{3}+ 3^{3}= 153

It is an Armstrong Number.View Answer16 Likes

## Java Iterative Stmts

Palindrome Number in Java: Write a program to accept a number from the user and check whether it is a Palindrome number or not. A number is a Palindrome which when reads in reverse order is same as in the right order.

Sample Input: 242

Sample Output: A Palindrome numberSample Input: 467

Sample Output: Not a Palindrome numberView Answer11 Likes

## 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 Answer4 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 Answer7 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 Answer25 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 Answer7 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 Answer19 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 Answer14 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 Answer14 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 Answer7 Likes

Showing 1 - 10 of 20 Questions