Open snr49 opened 6 years ago
MAIN: import java.util.; public class Main { public static void main(String[] args) { Scanner s=new Scanner(System.in); int n=s.nextInt(); System.out.println(UserMainCode.sumOfSquaresOfEvenDigits(n)); s.close(); } } USERMAINCODE: public class UserMainCode { public static int sumOfSquaresOfEvenDigits(int n) { int n1=0; int sum=0; while(n!=0) { n1=n%10; if(n1%2==0) { sum+=n1n1; } n=n/10; } return sum; } }
Write a program to read a number , calculate the sum of squares of even digits (values) present in the given number. Include a class UserMainCode with a static method sumOfSquaresOfEvenDigits which accepts a positive integer . The return type (integer) should be the sum of squares of the even digits. Create a class Main which would get the input as a positive integer and call the static method sumOfSquaresOfEvenDigits present in the UserMainCode. Input and Output Format: Input consists of a positive integer n. Output is a single integer . Refer sample output for formatting specifications. Sample Input 1: 56895 Sample Output 1: 100