Class 11 Computer Project Isc
Class 11 Computer Project Isc
Number or not.
Algorithm:
3. Iterate through the digit counts from 1 to 9 and check if each digit count is
equal to 1.
import java.util.Scanner;
public class KboatFascinatingNumber
return;
isFascinating = false;
break;
}
}
if (isFascinating)
else
Algorithm:
1. Start the program.
4. Extract the last digit of the number and assign it to the variable `lastDigit`.
7. Extract the rightmost digit of the number and assign it to the variable `digit`.
7. If both `increasing` and `decreasing` are true, the number is a bouncy number.
8. If either `increasing` or `decreasing` is true, but not both, the number is not a bouncy
number.
10. Print "The number is not a bouncy number" if it is not a bouncy number.
import java.util.Scanner;
if (n < 100) {
return;
int t = n;
while (t != 0) {
int d = t % 10;
if (d > prev) {
isIncreasing = false;
break;
prev = d;
t /= 10;
t = n;
prev = t % 10;
while (t != 0) {
int d = t % 10;
if (d < prev) {
isDecreasing = false;
break;
prev = d;
t /= 10;
else
}
Write a program in Java to display all the triangular numbers from 3 to n, taking
the value of n as an input.
Algorithm:
6. Calculate the triangular number using the formula: `(i * (i + 1)) / 2`.
8. Increment `i` by 1.
int n = in.nextInt();
if (n < 3) {
return;
+ n + ":");
System.out.println(sum);
sum += i;
Output
Write a program in Java to enter a number and check whether it is a Smith number or not.
import java.util.Scanner;
int n = in.nextInt();
if (n <= 0) {
if (n % i == 0) {
isComposite = true;
break;
if (isComposite && n != 1) {
int sumDigits = 0;
int t = n;
while (t != 0) {
int d = t % 10;
sumDigits += d;
t /= 10;
int sumPrimeDigits = 0;
t = n;
while(t % i == 0) {
t /= i;
int temp = i;
while (temp != 0) {
sumPrimeDigits += d;
temp /= 10;
if(t > 2) {
while (t != 0) {
int d = t % 10;
sumPrimeDigits += d;
t /= 10;
if (sumPrimeDigits == sumDigits)
else
else {
}
}
A unique-digit integer is a positive integer (without leading zeros) with no duplicates digits. For
example 7, 135, 214 are all unique-digit integers whereas 33, 3121, 300 are not. Given two
positive integers m and n, where m < n, write a program to determine how many unique-digit
integers are there in the range between m and n (both inclusive) and output them. The input
contains two positive integers m and n. Assume m < 30000 and n < 30000. You are to output
the number of unique-digit integers in the specified range along with their values in the format
specified below:
Sample Input:
m = 100
n = 120
Sample Output:
m = 2500
n = 2550
Sample Output:
2501, 2503, 2504, 2506, 2507, 2508, 2509, 2510, 2513, 2514, 2516, 2517, 2518, 2517, 2530,
2519, 2530, 2531, 2534, 2536, 2537, 2538, 2539, 2540, 2541, 2543, 2546, 2547, 2548, 2549.
import java.util.Scanner;
System.out.print("Enter m: ");
int m = in.nextInt();
return;
System.out.print("Enter n: ");
int n = in.nextInt();
if (n < 1 || n > 30000) {
return;
if (m > n) {
return;
int count = 0;
int num = i;
while (num != 0) {
if (visited[d]) {
isUnique = false;
break;
visited[d] = true;
num /= 10;
}
if (isUnique) {
count++;
System.out.println();
Accept two positive integers 'm' and 'n', where m is less than n. Display the
number of composite magic integers that are in the range between m and n
(both inclusive) and output them along with frequency, in the format specified
below:
Sample Input:
m=10 n=100
Sample Input:
m=120 n=90
import java.util.Scanner;
System.out.print("Enter m: ");
int m = in.nextInt();
System.out.print("Enter n: ");
int n = in.nextInt();
return;
int count = 0;
if (i % j == 0) {
isComposite = true;
break;
if (isComposite && i != 1) {
int num = i;
int sum = 0;
while (num != 0) {
num /= 10;
sum += d;
num = sum;
if (num == 1) {
count++;
System.out.println();
}
Write a program to accept an even integer 'N' where N > 9 and N < 50. Find all
the odd prime pairs whose sum is equal to the number 'N'.
import java.util.Scanner;
int c = 0;
if (num % i == 0) {
c++;
}
return c == 2;
int n = in.nextInt();
return;
if (n % 2 != 0) {
return;
int b = 0;
while (a <= n / 2) {
b = n - a;
a += 2;
}
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).
import java.util.Scanner;
num /= 10;
if (cubeSum == n)
return 1;
else
return 0;
}
int r = obj.armstrong(num);
if (r == 1)
else
}
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.
import java.util.Scanner;
int revNum = 0;
while(copyNum != 0) {
copyNum /= 10;
if (revNum == num)
else
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.
import java.util.Scanner;
int n = in.nextInt();
int c = 0;
if (n % i == 0) {
c++;
if (c == 2) {
}
else {
Write a menu driven program to accept a number from the user and check
whether it is a Prime number or an Automorphic number.
import java.util.Scanner;
switch (choice) {
case 1:
int c = 0;
if (num % i == 0) {
c++;
if (c == 2)
else
break;
case 2:
/*
* digits in num
*/
while(num > 0) {
d++;
num /= 10;
/*
*/
if (ld == numCopy)
else
break;
default:
System.out.println("Incorrect Choice");
break;
import java.util.Scanner;
int rev = 0;
while (num != 0) {
rev = rev * 10 + d;
num /= 10;
return rev;
if (num % i == 0) {
c++;
return c == 2;
int m = in.nextInt();
int n = in.nextInt();
int count = 0;
if (m >= n) {
System.out.println("INVALID INPUT");
return;
}
System.out.println("THE PRIME-ADAM INTEGERS ARE:");
if (adam) {
if (prime) {
count++;
if (count == 0) {
System.out.print("NIL");
System.out.println();
}
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 * 7
import java.util.Scanner;
if (i * (i + 1) == num) {
isPronic = true;
break;
if (isPronic)
else
}
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.
import java.util.Scanner;
int n = in.nextInt();
int sum = 0;
if (n % i == 0)
sum += i;
if (sum > n)
else
}
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).
import java.util.Scanner;
int digitSum = 0;
while (num != 0) {
num /= 10;
digitSum += digit;
/*
* 0 as input
*/
else
import java.util.Scanner;
int prod = 1;
sum += digit;
prod *= digit;
num /= 10;
if (sum == prod)
else
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
import java.util.Scanner;
while (num != 0) {
num /= 10;
digitSum += digit;
digitProduct *= digit;
count++;
}
if (count != 2)
else
Output
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.
import java.util.Scanner;
if (num == 1) {
else {
if (num % i == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
int t = num;
int revNum = 0;
while (t != 0) {
t /= 10;
if (revNum % i == 0) {
isPrime = false;
break;
if (isPrime)
System.out.println(num + " is a twisted prime number");
else
Write a program to enter two numbers and check whether they are co-prime or
not.
import java.util.Scanner;
System.out.print("Enter a: ");
int a = in.nextInt();
System.out.print("Enter b: ");
int b = in.nextInt();
int hcf = 1;
if (a % i == 0 && b % i == 0)
hcf = i;
if (hcf == 1)
else
System.out.println(a + " and " + b + " are not co-prime");
A number is said to be Duck if the digit zero is (0) present in it. Write a program
to accept a number and check whether the number is Duck or not. The program
displays the message accordingly. (The number must not begin with zero)
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
int c = 0, d;
/*
*/
char ch = (char)d;
if (c == 0 && ch == '0' )
firstZero = true;
isDuck = true;
c++;
if (isDuck)
System.out.println("Duck Number");
else
Write a program to display all the 'Buzz Numbers' between p and q (where p<q).
A 'Buzz Number' is the number which ends with 7 or is divisible by 7.
import java.util.Scanner;
System.out.print("Enter p: ");
int p = in.nextInt();
System.out.print("Enter q: ");
int q = in.nextInt();
if (p < q) {
if (i % 10 == 7 || i % 7 == 0)
System.out.println(i);
else {
System.out.println("Invalid Inputs!!!");
}
}