Disarium number Solved program
Disarium number Solved program: solved Java program for ICSE Class 10 Computer Applications with complete BlueJ code, explanation and sample output.
(Disarium number & reverse a number)
Design a menu driven program, that accepts an integer and displays the following menu : Displays the reverse of the number Displays whether the number is a Disarium number or not(Disarium number is a number whose digits raised to the power of their unit places sum is equal to the number. For example 135=11+32+53=1+9+125=135) exit
import java.util.*;
class Q1
{
public static void main()
{
System.out.println("Enter your choice");
Scanner s=new Scanner(System.in);
System.out.println("1:- reverse a number\n2:-checking the number disarium or not\n3:-exit");
int c=s.nextInt();
switch(c)
{
case 1:
System.out.println("Enter the number");
int n=s.nextInt();
int rev=0;
while(n!=0)
{
int rem=n%10;
rev=(rev*10)+rem;
n/=10;
}
System.out.println("Reversed number is:"+rev);
break;
case 2:
System.out.println("Enter a number");
int num=s.nextInt();
int a=num;
String nu=String.valueOf(num);
int i=nu.length();
int sum=0;
while(num!=0)
{
int rem=num%10;
sum+=(Math.pow(rem,i));
i--;
num/=10;
}
if(a==sum)
System.out.println("It is a Disarium number");
else
System.out.println("it is not a Disarium number");
break;
case 3:
System.exit(0);
break;
default:
System.out.println("Invalid number");
}
}
}Related Posts
Continue learning with these related articles
Sum of First n Natural Numbers in Java (Loop and Formula)
Find the sum of the first n natural numbers in Java with a for loop, a while loop and the formula n(n + 1)/2, with a dry run and the sums of even numbers, odd numbers, squares and cubes.
Prime Number Program in Java: Check a Number and Print Primes in a Range
Check whether a number is prime in Java by counting its factors, a faster square-root method with isPrime(), and a program that prints all prime numbers in a range.

Encapsulation, Access Specifiers and Scope of Variables in Java for ICSE Class 10
ICSE Class 10 Computer Applications notes on encapsulation: private, default, protected and public access, data hiding with getter and setter methods, instance vs static (class) variables, local variables and scope, with a solved BankAccount program.