interface InterfaceA {int method(int n);}class ClassA implements InterfaceA{@Overridepublic int method(int n) {int result = 0;for(int i = 1; i<=n; i++){result+=i;}return result;}}class ClassB implements InterfaceA{@Overridepublic int method(int n) {int result = 1;for(int i = 1; i<=n; i++){result*=i;}return result;}}public class E{public static void main(String[] args) {ClassA a = new ClassA();System.out.println("1+2+3+...+6="+a.method(6));ClassB b = new ClassB();System.out.println("7!="+b.method(7));}}
interface InterfaceA {int method(int n);}class ClassA implements InterfaceA{@Overridepublic int method(int n) {int result = 0;for(int i = 1; i<=n; i++){result+=i;}return result;}}class ClassB implements InterfaceA{@Overridepublic int method(int n) {int result = 1;for(int i = 1; i<=n; i++){result*=i;}return result;}}public class E{public static void main(String[] args) {ClassA a = new ClassA();System.out.println("1+2+3+...+6="+a.method(6));ClassB b = new ClassB();System.out.println("7!="+b.method(7));}}