import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a, b, c, d, e;
a = in.nextInt();
b = in.nextInt();
c = in.nextInt();
d = in.nextInt();
e = in.nextInt();
Test rr = new Test();
int dd = rr.sum(a, b, c, d, e);
System.out.println(dd);
}
}
/* 请在这里填写答案 */
输入样例
1 2 3 4 5
输出样例
15
代码
class Test
{
public int sum(double...values){//接受若干个值,values为最后一个接收的值
int result=0;
for(double i:values){
result+=i;
}
return result;
}
}
设计类Test,实现若干个数的累加功能。 请补充以下代码,完成输出要求。函数接口定义class Test{}裁判测试程序样例import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int a, b, c, d, e; a = in.nextInt()