Q)... A integer input is
accepted. find the square of individual digits and find their sum.
input:125
output:1*1+2*2+5*5
input:125
output:1*1+2*2+5*5
- package Set1;
- import java.util.*;
- public class ClassSet16 {
- public static int averageOfMarks(Map<Integer,Integer> m1){
- int n=0,c=0;
- Iterator<Integer> i=m1.keySet().iterator();
- while(i.hasNext()){
- Integer b=i.next();
- if(b%2!=0){
- c++;
- n+=m1.get(b);} }
- return (n/c);
- }
- public static void main(String[] args) {
- Map<Integer,Integer> m1=new HashMap<Integer,Integer>();
- m1.put(367, 89);
- m1.put(368, 98);
- m1.put(369, 92);
- m1.put(366, 74);
- m1.put(365, 67);
- System.out.println(averageOfMarks(m1));
- }
- }