To check if a number is Armstrong number using java -


this program:

public class armstrongnumber {      public static void main(string args[]) {         int n = 0, temp = 0, r = 0, s = 0;         scanner in = new scanner(system.in);         system.out.println("enter number ");         if (in.hasnextint()) {             n = in.nextint(); // if there number           } else {             n = 0;         }         temp = n;         while (n != 0) {             r = n % 10;             s = s + (r * r * r);             n = n / 10;         }          if (temp == s) {             system.out.println(n + " armstrong number");         } else {             system.out.println(n + " not armstrong number");         }     } }   

output:

exception in thread "main" java.lang.noclassdeffounderror

i tried using datainputstream still getting same error.

you need set class_path variable , point ever class file is

then should work

i have tried locally, refer my answer check how set class path , how compile , run java code using command prompt


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -