Get Website Learn Coding Tech Story

Java Programming Examples

import java.io.*;

class checking {

	/* Constructor of the class */
	checking(int number) {
		int a =  number, mod, ans = 0;

		/* Loop the process using 'while' */
		while(a != 0) {
			mod = a % 10;
			ans += (mod * mod * mod);
			a = a / 10;
		}
		if(ans == number)
			System.out.println("It's a Armstrong number");
		else
			System.out.println("It's not a Armstrong number");
	}
}
										
class armstrong {
	public static void main(String args[ ]) {

		/* Create object of 'checking' class and pass value to it's constructor */	
		checking obj = new checking(Integer.parseInt(args[0]));										
	}
}


          /****** Output ******/
          

java armstrong 123


It's not a Armstrong number




------------------------------




java armstrong 153


It's a Armstrong number

Learn more about Armstrong Number