Java Program To Check Armstrong Number

Check Armstrong number

About Armstrong Number

Definition for Armstrong number:

An Armstrong number is a sum of ‘nth’ power of each digit. ‘n’th digit is equal to n digit of a number.
153 = 111 + 555 + 333 — 153 is an Armstrong number
371 = 333 + 777 + 111 — 371 is an Armstrong number

Logic to implemented in program:

  • Get input from keyboard
  • Get total number of digit in given input digit
  • Save input in temp variable for comparison purpose
  • Find the sum of ‘nth’ power of each digit. here n is number of digit in given input number
  • Display the output

1. Check Armstrong number without scanner class

import java.util.Scanner;

public class ArmstrongNo {

	public static void main(String[] args) {
		int inputvalue= 371; // Given number
		int temp =  inputvalue, finalresult=0, rem=0,count =0;		
		//Get total number of digit of given number
			inputvalue = inputvalue/10;
			count ++;
		//Restore given data to same variable
		inputvalue =  temp;
		//Find the sum of 'nth' power of each digit. here 'n' is number of digit in given input number.		
			rem = inputvalue%10;
			inputvalue = inputvalue/10;
			finalresult = finalresult + (int) Math.pow(rem, count);
		//Display the output
			System.out.println("Number *"+temp+"* is Armstrong");
			System.out.println("Number *"+temp+"* is Not Armstrong");
Number *371* is armstrong

2. Check Armstrong number with scanner class

import java.util.Scanner;

public class ArmtrongNumber {

	public static void main(String[] args) {
		//Create object for Scanner class to get input digit from keyboard
		Scanner scn = new Scanner(;
		//Get input digit from keyboard
		System.out.print("Enter number : ");		
		int inputvalue = scn.nextInt();		
		int temp =  inputvalue, finalresult=0, rem=0,count =0;		
		//Get total number of digit of given number
			inputvalue = inputvalue/10;
			count ++;
		//Restore given data to same variable
		inputvalue =  temp;
		//Find the sum of 'nth' power of each digit. here 'n' is number of digit in given input number.		
			rem = inputvalue%10;
			inputvalue = inputvalue/10;
			finalresult = finalresult + (int) Math.pow(rem, count);
		//Display the output
			System.out.println("Number *"+temp+"* is Amstrong");
			System.out.println("Number *"+temp+"* is Not Amstrong");
Output 1:
Enter number : 123
Number *123* is Not Amstrong

Output 2:
Enter number : 371
Number *371* is Amstrong

Recommended article:

Hey, Now it is your time! Drop a comment if more details needed or if any update requires. Your comments are more valuable to improve our site to help others.

111 thoughts on “Java Program To Check Armstrong Number”

  1. Fantastic site you have here but I was wanting to know if you knew of any forums that cover the same topics talked about here? I’d really love to be a part of online community where I can get feed-back from other experienced individuals that share the same interest. If you have any recommendations, please let me know. Thanks a lot!

  2. I am really inspired with your writing abilities as smartly as with the layout in your blog.

    Is that this a paid theme or did you modify it your
    self? Either way keep up the nice high quality writing, it is uncommon to
    see a great weblog like this one nowadays..

  3. Thank you for the auspicious writeup. It in fact was a amusement account
    it. Look advanced to far added agreeable from you!

    However, how can we communicate?

  4. of course like your web-site however you need to check the spelling on several of your posts.
    Several of them are rife with spelling issues and
    I find it very troublesome to tell the reality nevertheless I’ll definitely come again again.

  5. Hey! Someone in my Facebook group shared this site
    with us so I came to check it out. I’m definitely loving the information. I’m book-marking and will be tweeting this to my followers!
    Great blog and amazing design.

  6. Hiya! I know this is kinda off topic however , I’d figured I’d ask.

    Would you be interested in trading links or maybe
    guest writing a blog post or vice-versa? My site goes over a
    lot of the same topics as yours and I think we
    could greatly benefit from each other. If you’re interested
    feel free to shoot me an email. I look forward to
    hearing from you! Superb blog by the way!

  7. Hi there would you mind letting me know which hosting company you’re working with?
    I’ve loaded your blog in 3 completely different web
    browsers and I must say this blog loads a lot faster then most.

    Can you recommend a good hosting provider at a honest price?
    Many thanks, I appreciate it!

  8. I really like your blog.. very nice colors & theme. Did you make this website yourself or did you hire someone to do it for you?

    Plz respond as I’m looking to design my own blog and would like to find out where
    u got this from. thanks a lot

  9. Hey just wanted to give you a quick heads up and let you know a few of the images aren’t loading correctly.
    I’m not sure why but I think its a linking issue.

    I’ve tried it in two different web browsers and both show the same results.

  10. Howdy! Do you know if they make any plugins to assist with Search Engine Optimization?
    I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good success.
    If you know of any please share. Cheers!

  11. The other day, while I was at work, my sister stole my apple
    ipad and tested to see if it can survive a 40 foot drop,
    just so she can be a youtube sensation. My apple ipad is now destroyed and she has 83 views.
    I know this is completely off topic but I had to share it with someone!

  12. I was pretty pleased to discover this site. I want
    to to thank you for your time for this particularly wonderful read!!

    I definitely really liked every bit of it and I have you book marked to look at new things on your website.

  13. Hey, I think your site might be having browser compatibility issues.

    When I look at your blog site in Firefox, it looks fine but when opening in Internet
    Explorer, it has some overlapping. I just wanted to give you
    a quick heads up! Other then that, very good blog!

  14. Currently it appears like Drupal is the preferred blogging platform
    out there right now. (from what I’ve read) Is that what you’re using on your blog?

  15. Hi, I do believe this is an excellent website. I stumbledupon it 😉 I’m going to return yet again since I saved as a favorite it.
    Money and freedom is the best way to change, may you be rich
    and continue to help others.

  16. I like the valuable info you supply on your articles.
    I’ll bookmark your blog and check again right here frequently.

    I’m rather sure I will be informed mmany new stuff proper here!
    Best of luck for the next!

  17. Admiring the hard work you put into your site and in depth information you
    present. It’s nice to come across a blog every once in a while that isn’t the same old rehashed information. Excellent read!
    I’ve saved your site and I’m including your RSS feeds to my Google account.

  18. You actually make it seem so easy together with your presentation but I to find this matter to be actually something which I think I would never understand.

    It seems too complex and very huge for me. I am having a look
    forward on your next submit, I’ll try to get the hold of it!

  19. I know this if off topic but I’m looking into starting my own weblog and was curious what all is needed to get set up?
    I’m assuming having a blog like yours would cost
    a pretty penny? I’m not very internet smart so I’m not 100% certain. Any recommendations or advice would be greatly
    appreciated. Thank you

  20. This is very interesting, You’re a very professional blogger.
    I have joined your rss feed and stay up for looking for more of your great
    post. Also, I have shared your site in my social networks

  21. I think that is among the most significant info for me. And i’m glad reading your article.
    But should observation on few normal issues, The web site style is wonderful,
    the articles is in point of fact nice : D.
    Excellent task, cheers

  22. Excellent weblog here! Also your web site loads up fast!
    What web host are you the usage of? Can I am getting your associate link on your host?
    I want my site loaded up as quickly as yours lol

  23. Spot on with this write-up, I actually think this amazing site needs
    a lot more attention. I’ll probably be back again to
    read through more, thanks for the info!

  24. I love your blog.. very nice colors & theme. Did you create
    this website yourself or did you hire someone to do it for
    you? Plz answer back as I’m looking to construct my own blog
    and would like to find out where u got this from. thanks
    a lot

  25. It’s a pity you don’t have a donate button! I’d definitely donate to this fantastic blog!
    I suppose for now i’ll settle for bookmarking and adding your
    RSS feed to my Google account. I look forward to new updates and will share this blog
    with my Facebook group. Chat soon!

  26. Its like you read my mind! You seem to know a lot about this, like you wrote the book in it or something.
    I think that you can do with some pics to drive the message
    home a bit, but instead of that, this is wonderful blog.
    A fantastic read. I’ll definitely be back.

  27. Hey there this is kind of of off topic but I was wondering if blogs use WYSIWYG editors or if
    you have to manually code with HTML. I’m starting a blog soon but have no coding know-how so I wanted to get
    advice from someone with experience. Any help would be enormously

  28. I was recommended this web site by way of my cousin. I am no longer positive whether
    this put up is written through him as nobody else realize such unique approximately my difficulty.
    You are wonderful! Thank you!

  29. Write more, thats all I have to say. Literally, it seems as though you relied
    on the video to make your point. You obviously know what youre
    talking about, why waste your intelligence on just posting videos to your weblog when you could
    be giving us something informative to read?

  30. Oh my goodness! Amazing article dude! Many thanks, However I am encountering issues with your RSS.

    I don’t understand the reason why I can’t subscribe to it.
    Is there anybody else having the same RSS issues?
    Anybody who knows the answer can you kindly respond? Thanx!!

  31. I’m really enjoying the theme/design of your weblog.
    Do you ever run into any internet browser compatibility issues?
    A number of my blog visitors have complained about my website not working correctly in Explorer but looks great in Chrome.
    Do you have any solutions to help fix this problem?

  32. Hello! I know this is somewhat off-topic however I had to ask.
    Does building a well-established blog such as yours require
    a lot of work? I am completely new to operating a
    blog however I do write in my diary daily.
    I’d like to start a blog so I can easily share my experience and views online.
    Please let me know if you have any kind of ideas or tips for new aspiring blog owners.

  33. I do accept as true with all of the ideas you’ve introduced on your post.

    They’re really convincing and will definitely work.
    Nonetheless, the posts are very brief for newbies. Could you please lengthen them
    a little from subsequent time? Thanks for the post.

  34. My spouse and I stumbled over here by a different web page and thought I may as well check things out.
    I like what I see so now i am following you. Look forward to looking at your web page again.

  35. you are actually a excellent webmaster. The web site loading pace is
    amazing. It seems that you’re doing any distinctive
    trick. Moreover, The contents are masterpiece.
    you’ve performed a excellent process in this subject!

  36. Excellent beat ! I wish to apprentice while you amend your website, how could i subscribe
    for a weblog website? The account helped me a appropriate deal.
    I had been tiny bit familiar of this your broadcast provided brilliant
    clear concept

  37. Very nice post. I just stumbled upon your weblog and wished to say that I have truly
    enjoyed browsing your blog posts. After all I’ll be subscribing to your feed
    and I hope you write again soon!

  38. I am not sure where you’re getting your info,
    but good topic. I needs to spend some time learning
    more or understanding more. Thanks for wonderful information I was looking for this
    information for my mission.

  39. Oh my goodness! Impressive article dude! Thanks,
    However I am encountering problems with your RSS.
    I don’t understand why I am unable to subscribe to it.

    Is there anyone else having identical RSS issues?

    Anyone that knows the solution can you kindly respond?


  40. Thanks for one’s marvelous posting! I quite enjoyed reading it, you will be a great author.
    I will always bookmark your blog and will come back sometime soon. I want to encourage
    you to continue your great job, have a nice day!

  41. It’s the best time to make a few plans for the future and it’s time to be happy.
    I’ve read this put up and if I may just I
    desire to counsel you few fascinating issues or suggestions.
    Maybe you could write subsequent articles referring to this article.
    I wish to learn even more things approximately it!

  42. Pingback: Google

  43. Hello there, I discovered your site by means of Google
    at the same time as looking for a similar topic, your site came up, it seems good.
    I’ve bookmarked it in my google bookmarks.
    Hello there, just turned into alert to your weblog through Google, and found that
    it is really informative. I’m going to watch out for
    brussels. I will be grateful if you proceed this in future.
    A lot of folks can be benefited out of your writing.

  44. Pingback: Google

  45. Thanks for one’s marvelous posting! I actually
    enjoyed reading it, you can be a great author.I will be sure to
    bookmark your blog and will come back in the future.

    I want to encourage you to continue your great posts, have a nice day!

  46. Excellent post. Keep posting such kind of info on your page.
    Im really impressed by it.
    Hey there, You’ve done an incredible job. I’ll definitely
    digg it and individually suggest to my friends. I’m confident they’ll be benefited from
    this site.

  47. I’m curious to find out what blog system you happen to be using?
    I’m having some small security issues with my latest website and I’d like to find
    something more safe. Do you have any recommendations?

  48. Hmm it looks like your blog ate my first comment (it was extremely long) so I guess I’ll
    just sum it up what I had written and say, I’m thoroughly enjoying your
    blog. I as well am an aspiring blog writer but I’m still
    new to the whole thing. Do you have any tips for inexperienced blog writers?
    I’d certainly appreciate it.

Leave a Comment

Your e-mail address will not be published. Required fields are marked *