@@ -0,0 +1,1762 @@
+package thirty_days_of_code;%0D%0A%0D%0Aimport java.util.Scanner;%0D%0A%0D%0A/*%0D%0A * Problem Statement:%0D%0A * Here you are given an interface AdvancedArithmetic which contains a method%0D%0A * signature%0D%0A * %0D%0A * int divisorSum(int n). (The divisorSum function just takes an integer as%0D%0A * input and return the sum of all its divisors.) %0D%0A * Your only task is to write a class Calculator which implements the interface.%0D%0A * %0D%0A * Note : The class Calculator shouldn't be public.%0D%0A * %0D%0A * Input Format: %0D%0A * Only one line containing integer n%0D%0A * %0D%0A * Constraints:%0D%0A * 1 %3C= n %3C= 1000%0D%0A * %0D%0A * Output Format: %0D%0A * In the first line print %22I implemented: AdvancedArithmetic%22 without quotes.%0D%0A * In the next line print the sum of divisors of n as given in problem%0D%0A * statement.%0D%0A * %0D%0A * Sample Input: %0D%0A * 6%0D%0A * %0D%0A * Sample Output: %0D%0A * I implemented: AdvancedArithmetic%0D%0A * 12%0D%0A */%0D%0Apublic class Interfaces %7B%0D%0A%0D%0A    public static void main(String%5B%5D args) %7B%0D%0A        Scanner sc=new Scanner(System.in);%0D%0A        int n=sc.nextInt();%0D%0A      %09AdvancedArithmetic myCalculator=new DivisorCalculator(); %0D%0A        int sum=myCalculator.divisorSum(n);%0D%0A        System.out.println(%22I implemented: AdvancedArithmetic%5Cn%22+sum);%0D%0A        sc.close();%0D%0A    %7D%0D%0A%7D%0D%0A%0D%0Aclass DivisorCalculator implements AdvancedArithmetic %7B%0D%0A    %0D%0A    public int divisorSum(int n) %7B%0D%0A        %0D%0A        int maxDivisor = (int) Math.sqrt(n);%0D%0A        int sum = 0;%0D%0A        %0D%0A        for (int i = 1; i %3C= maxDivisor; i++) %7B%0D%0A            if (n %25 i == 0) %7B%0D%0A                sum += i;%0D%0A                %0D%0A                int d = n / i;%0D%0A                if (d != i) %7B%0D%0A                    sum += d;%0D%0A                %7D%0D%0A            %7D%0D%0A        %7D%0D%0A        return sum;%0D%0A    %7D%0D%0A%7D%0D%0A%0D%0Ainterface AdvancedArithmetic %7B%0D%0A%09int divisorSum(int n);%0D%0A%7D

Add Interfaces