2 回答
largeQ
TA贡献2039条经验 获得超7个赞
import java.util.Scanner;
public class Add{
public static void mian(String[] args) {
System.out.println("请输入被加数a:");
Scanner scanner1 = new Scanner(System.in);
int num1 = scanner1.nextInt();
System.out.println("请输入被加数b");
Scanner scanner2 = new Scanner(System.in);
int num2 = scanner2.nextInt();
int sum = add(num1,num2);
System.out.println("a + b = " + sum);
}
static int add(int a, int b) {
return a+b;
}
}
public class Add{
public static void mian(String[] args) {
System.out.println("请输入被加数a:");
Scanner scanner1 = new Scanner(System.in);
int num1 = scanner1.nextInt();
System.out.println("请输入被加数b");
Scanner scanner2 = new Scanner(System.in);
int num2 = scanner2.nextInt();
int sum = add(num1,num2);
System.out.println("a + b = " + sum);
}
static int add(int a, int b) {
return a+b;
}
}
添加回答
举报
0/150
提交
取消