JAVA_方法_输入两个数打印他们的和差积商

import java.util.Scanner;


public class twoint {

public static void main(String[] args){
twonum();
}
public static int twonum(){
System.out.println("输入两个数,得出加减乘除");
Scanner scan = new Scanner(System.in);

System.out.println("请输入第一个数:");
int num1 = scan.nextInt();

System.out.println("请输入第二个数:");
int num2 = scan.nextInt();

int nnplu = num1+num2;
int nnsub = num1-num2;
int nnmul = num1*num2;
int nndiv = num1/num2;
System.out.println(num1+"与"+num2+"的和为:"+nnplu);
System.out.println(num1+"与"+num2+"的差为:"+nnsub);
System.out.println(num1+"与"+num2+"的积为:"+nnmul);
System.out.println(num1+"与"+num2+"的商为:"+nndiv);
return 0;
}

}

//最后的return,还不清楚,稍后补充

你可能感兴趣的:(JAVA,基础知识)