From 5d91923058d24486fb264d2f517f797b9bd1ea96 Mon Sep 17 00:00:00 2001 From: binaryshrey Date: Tue, 1 Oct 2019 17:00:12 +0530 Subject: [PATCH] ARMSTRONG no in JAVA --- SOLUTIONS/Armstrong.java | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 SOLUTIONS/Armstrong.java diff --git a/SOLUTIONS/Armstrong.java b/SOLUTIONS/Armstrong.java new file mode 100644 index 00000000..b033f85c --- /dev/null +++ b/SOLUTIONS/Armstrong.java @@ -0,0 +1,28 @@ +/* package codechef; // don't place package name! */ + +import java.util.*; +import java.lang.*; +import java.io.*; + +/* Name of the class has to be "Main" only if the class is public. */ +class Codechef +{ + public static void main (String[] args) throws java.lang.Exception + { + // your code goes here + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int no = n; + int d=0,sum=0; + while(no>0){ + d = no%10; + sum+=d*d*d; + no = no/10; + } + if(sum == n) + System.out.println(n+" is an armstrong number"); + else + System.out.println(n+" is not an Armstrong Number"); + + } +}