public class Sumn { public static void main(String args[]){ System.out.println("整数和"); Sum s1=new Sum(); s1.print(); System.out.println("偶数和"); Sumn1 s2=new Sumn1(); s2.print(); System.out.println("阶乘和"); Sumn2 s3=new Sumn2(); s3.print(); } } public class Sum { int sum=0; int n; public int sum(int n){ int x=0; for(int i=1;i<=n;i++){ x=x+i; } int s=x; return s; } public void print(){ System.out.println(sum(10)); } } public class Sumn1 { int sumn=0; int n; public int sumn(int n){ int x=0; for(int i=2;i<=n;i=i+2){ x=x+i; } int s=x; return s; } public void print(){ System.out.println(sumn(10)); } } public class Sumn2 { public int sumn2(int n){ int x=1; for(int i=1;i<=n;i++){ x=x*i; } int s=x; return s; } public void print(){ System.out.println(sumn2(10)); } }