Upload files to "OOP/Java/Lab/Week3"

This commit is contained in:
Aadit Agrawal 2024-08-10 11:20:04 +05:30
parent d7432df050
commit 490ff117eb
3 changed files with 74 additions and 27 deletions

View file

@ -1,4 +1,5 @@
import java.util.Scanner;
import java.lang.Math;
class Armstrong{
public static void main(String args[]){
@ -6,15 +7,23 @@ class Armstrong{
int a,b,digit;
int digisum=0;
int c=0;
System.out.println("Enter the number you went to check for Armstrong-ness:");
a = sc.nextInt();
b = a;
while(b!=0){
c++;
b/=10;
}
b = a;
while(b!=0){
digit = b%10;
digisum += (digit*digit*digit);
digisum += Math.pow(digit, c);
b /= 10;
}