package whitebox;
import java.util.Scanner;
public class judgment {
public static void main(String arg[]) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
judgment test = new judgment();
test.comfirm(a, b, c);
}
public void comfirm(int a, int b, int c) {
if (1 <= a && a <= 100 && 1 <= b && b <= 100 && 1 <= c && c <= 100) {
if (a + b > c && a + c > b && b + c > a) {
System.out.println("是三角形");
} else {
System.out.println("不是三角形");
}
}
else if(a<0||b<0||c<0) {
System.out.println("不是三角形");
}
else{System.out.println("不在测试范围内");}
}
}
package blackbox;
import java.util.Scanner;
public class Computer {
private int a;
private int b;
public Computer(int x, int y) {
a = x;
b = y;
}
public int add() {
return a + b;
}
public int minu() {
return a - b;
}
public int mult() {
return a * b;
}
public double div() {
if (b != 0)
return (double) a / b;
else
System.out.println("除数不能为0");
return 0;
}
public static void main(String arg[]) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入0~100的两个m,n整数:");
System.out.print("请输入第一个数:");
while (true) {
int m = sc.nextInt();
if (m >= 0 && m <= 100) {
System.out.print("请输入第二个数:");
while (true) {
int n = sc.nextInt();
if (n >= 0 && n <= 100) {
Computer cpt = new Computer(m, n);
System.out.println("运算结果是:");
System.out.println("加法:" + m + "+" + n + "=" + cpt.add());
System.out.println("减法:" + m + "-" + n + "=" + cpt.minu());
System.out.println("乘法:" + m + "*" + n + "=" + cpt.mult());
if (n == 0) {
System.out.println("除数不能为0");
System.out.print("输入n值不在要求区间,请重新输入:");
} else
System.out.println("除法:" + m + "/" + n + "=" + cpt.div());
} else
System.out.print("输入n值不在要求区间,请重新输入:");
}
} else
System.out.print("输入m值不在要求区间,请重新输入:");
}
}
}