jhvghvgk
;nkjn
,nkjhj
This is a programming blog that covers the complete syllabus of ICSE computer science.it helps you to solve your java programming related doubts and queries.number programs, series programs, pattern programs, array programs, string programs, function programs, constructor programs, method overloading programs, constructor overloading programs, exceptional handling programs, inheritance programs.
import java.util.*;public class Happy_num{public static void main(String args[ ]){Scanner sc = new Scanner (System.in);System.out.println("Enter a number");int a = sc.nextInt();int s = 10;while(s>9){s=0;while(a>0){int d = a%10;int x = (int)Math.pow(d,2);a = a/10;s=s+x;}a=s;}if(s==1){System.out.println("Entered number is a HAPPY Number");}else{System.out.println("Entered number is not a HAPPY Number");}}}
happy-number Write a program to input a number and
check whether it is Magic Number or
not? ( 64 = 6+4 = 10 = 1+0 = 1) |
import java.util.*;
public class Magic_num
{
public static void main(String args[ ])
{
Scanner sc = new Scanner (System.in);
System.out.println("Enter a number");
int a = sc.nextInt();
int s = 10;
while(s>9)
{
s=0;
while(a>0)
{
int d = a%10;
a = a/10;
s=s+d;
}
a=s;
}
if(s==1)
{
System.out.println("Entered number is a MAGIC Number");
}
else
{
System.out.println("Entered number is not a MAGIC Number");
}
}}
import java.util.*;public class Amicable_pair_num{public static void main(String args[ ]){Scanner sc = new Scanner (System.in);System.out.println("Enter two numbers");int a = sc.nextInt();int b = sc.nextInt();int m = 0;int n = 0;for(int i = 1;i<a;i++){if(a%i==0){m=m+i;}}for(int i = 1;i<b;i++){if(b%i==0){n=n+i;}}if(m==b&&n==a){System.out.println("Entered number are AMICABLE PAIR Number ");}else{System.out.println("Entered number are not AMICABLE PAIR Number ");}}}
amicable-pair-number Write a program to input a number and
Swap the first and last digit of
this number?(2784===4782) |
import java.util.*;public class Swap_first_last_digit{public static void main(String args[ ]){Scanner sc = new Scanner (System.in);System.out.println("Enter a number");int a = sc.nextInt();int k = a;int c = 0;while(k>0){k=k/10;c++;}int m = (int)Math.pow(10,c-1);int n = a%m;int t = a/m;int r = n%10;n=n/10;n=(n*10)+t;n=(r*m)+n;System.out.println("Number after SWAPING First and Last Digit = "+n);}}
import java.util.*;public class Adam_num{public static void main(String args[ ]){Scanner sc = new Scanner (System.in);System.out.println("Enter a number");int a = sc.nextInt();int p = a*a;int r = 0;while(a>0){int d = a%10;r=(r*10)+d;a=a/10;}int p1 = r*r;r=0;while(p1>0){int d = p1%10;r=(r*10)+d;p1=p1/10;}if(p==r){System.out.println("Entered number is a ADAM Number");}else{System.out.println("Entered number is not a ADAM Number");}}}
import java.util.*;public class Disarium_num{public static void main(String args[ ]){Scanner sc = new Scanner (System.in);System.out.println("Enter a number");int a = sc.nextInt();int k = a;int c = 0;while(k>0){k=k/10;c++;}int r = 0;k=a;for(int i = c;i>=1;i--){int d = k%10;int x = (int)Math.pow(d,i);r=r+x;k=k/10;}if(r==a){System.out.println("Entered number is a DISARIUM Number");}else{System.out.println("Entered number is not a DISARIUM Number");}}}
jhvghvgk ;nkjn ,nkjhj