import java.util.Scanner;
public class Sum {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("请输入范围是-40到40之间的三个数,中间用空格分开");
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
int y = sc.nextInt();
int z = sc.nextInt();
add(x,y,z);
}
public static void add(int x,int y,int z) {
if((x>-40&&x<40)&&(y>-40&&x<40)&&(z>-40&&z<40)){
int sum = x+y+z;
System.out.println(sum);
}else{
System.out.println("超出取值范围");
}
}
}
|
-
1.PNG
(2.17 KB, 下载次数: 36)
|