Armstrong Number, Palindrome Number, Prime Number, Even Number, Odd Number All In A Single Program

Armstrong number & Palindrome number & Prime number & Even number & Odd number

java program

In below program Armstrong number, Palindrome number, Prime number, Even Number, Odd number get all together in a single java program. Below I have shown you a simple java example of Java Inheritance, Which is also an example of Oop or objects oriented program. Let’s check Factorial number java program.

In this program, users are required to give a single input to get output for Armstrong number, Palindrome number, Prime number, Even Number, Odd number. In a below-designed java program, I have specially handover java function to each one separately to make it in easier in understanding. check Reverse number in java.

Note:- Most important things in this java program.

Armstrong number + Palindrome number +  Prime number + Even Number + Odd number

Here in below, I have noted down all the java program and I have assembled all in one. So now let’s check it and care. Get a repeated character in java.

Note: >   First

armstrong program

1| import java.util.*;
2| public class class_main_methods{
3| public static void main(String[] args){
4| Scanner input=new Scanner(System.in);
5| System.out.print(“Your Number -> “);
6| int number=input.nextInt();
7| int length=String.valueOf(number).length();
8| System.out.println();
9| class_final_call obj=new class_final_call();
10| obj.initionalize_value( number, length);
11| obj.final_call();
12| }
13| }
Note: >   Second
1| public class class_initionalize_value{
2| static int num;
3| static int length_number;
4| static void initionalize_value( int x, int y){
5| num=x;
6| length_number=y;
7| }
8| }
Note:  Third
1| public class class_armostrong_number extends class_initionalize_value{
2| static int armostrong_number(){
3| int value=num;
4| int valu1=num;
5| int reminder;
6| int sum=0;
7| for (int i=0; i<length_number; i++){
8| reminder= valu1%10;
9| int multi=1;
10| for(int j=0; j<length_number; j++){
11| multi= multi*reminder;
12| }
13| sum=sum+multi;
14| valu1=valu1/10;
15| }
16| return (sum);
17| }
18| }
Note: > Forth
1| public class class_palidrom_number extends class_armostrong_number{
2| static int palidrom_number(){
3| int number_for_pali=num;
4| int total=0;
5| int reminder=0;
6| for (int i=0; i<length_number; i++){
7| reminder=number_for_pali%10;
8| total=total*10+reminder;
9| number_for_pali=number_for_pali/10;
10| }
11| return (total);
12| }
13| }
Note: > Forth
1| public class class_odd_number extends class_palidrom_number{
2| static int odd_number(){
3| int temp1=0;
4| if (num%2==0){
5| temp1=temp1+1;
6| }
7| return (temp1);
8| }
9| }
Note: > Forth
1| public class class_prime_number extends class_odd_number{
2| static int prime_number(){
3| int temp=0;
4| for (int i=2; i<length_number-1; i++){
5| if(num%i==0){
6| temp=temp+1;
7| }
8| }
9| return (temp);
10| }
11| }
Note: > Forth
1| public class class_final_call extends class_prime_number{
2| static void final_call(){
3| if ( armostrong_number()==num){
4| System.out.println(“This is armostrong number -> “+num);
5| }
6| if (palidrom_number()==num){
7| System.out.println(“This is palindrome number -> “+num);
8| }
9| if (odd_number()>0){
10| System.out.println(“This is even number-> “+num);
11| }
12| if (odd_number()<1){
13| System.out.println(“This is odd number-> “+num);
14| }
15| if (prime_number()>0){
16| System.out.println(“This is prime number-> “+num);
17| }
18| }
19| }

Output for java program

Prime number, Armstrong number

Final comment on Prime number, Armstrong number, Even number, Palindrome number, Odd number

Above designed “Armstrong number”together with all program to get all output in a single java program. In this article, I have shown you how to simplify all java program together. Above users having the opportunity to download the program for java. Get sum of minimum and maximum.

In case of having any dought using the java code use below comment box to send to me problem query regarding the java code that I come with a possible alternative to make you better understand.

Keep connected with https://infosorce.com

Comments

  1. Thanks for your online teaching.

Speak Your Mind

*

error: Content is protected !!
DMCA.com Protection Status