[求助]数列求和
class Shulie
{
int a,d,n,sum;
void setA(a)
{
this.a=a;
}
public void setD(d)
{
this.d=d;
}
public void setN(n)
{
this.n=n;
}
public void setSum(a)
{
this.Sum=a;
}
Shulie he()
{
inti=1;
for(i=1,i<=n,i++)
{
sum=sum+d;
}
return sum;
}
}
public class lp0
{
public static void main(String arg[])
{
Shulie shulie=new he();
shulie.setA(2);
shulie.setN(10);
shulie.setD(2);
shulie.setSum();
System.out.println("数列和是"+shulie.setSum());
}
}