2 回答

largeQ
TA貢獻(xiàn)2039條經(jīng)驗(yàn) 獲得超8個(gè)贊
import java.util.Scanner;
public class Add{
public static void mian(String[] args) {
System.out.println("請輸入被加數(shù)a:");
Scanner scanner1 = new Scanner(System.in);
int num1 = scanner1.nextInt();
System.out.println("請輸入被加數(shù)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("請輸入被加數(shù)a:");
Scanner scanner1 = new Scanner(System.in);
int num1 = scanner1.nextInt();
System.out.println("請輸入被加數(shù)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;
}
}
添加回答
舉報(bào)
0/150
提交
取消