二. 边界值分析法
设销售额为X元,佣金为Y元;设主控模块销售数量为a个,通信模块销售数量为b个,执行模块销售数量为c个.
X<Y 无效输出
a>80或a<1 无效输出
b>90 或 b<1 无效输出
c>100 或 c<1 无效输出
边界值按(数量最左边界附近,数量中间常规值,数量最右边界附近)
a的边界值={0,1,2,40,79,80,81}
b的边界值={0,1,2,45,89,90,91}
c的边界值={0,1,2,50,99,100,101}
/**
* @author WangJiaHui
* @description:
* @ClassName Test
* @date 2022/9/5 16:27
*/
public class Test {
static int[] a = {1, 2, 40, 79, 80, 81};
static int[] b = {1, 2, 45, 89, 90, 91};
static int[] c = {1, 2, 50, 99, 100, 101};
static int sumA = 60 * 45 + 50 * 50;
static int sumB = 90 * 40 + 50 * 50;
static int sumC = 90 * 40 + 60 * 45;
public static void main(String[] args) {
for (int i = 0; i < a.length; i++) {
int iA = a[i] * 90 + sumA;
int iB = b[i] * 60 + sumB;
int iC = c[i] * 50 + sumC;
sum('a', iA, a[i]);
sum('b', iB, b[i]);
sum('c', iC, c[i]);
System.out.println("=====================");
}
}
public static void sum(char letter, int sale, int arr) {
if (sale <= 1000) {
System.out.println("现在的" + letter + "数量为: " + arr + ",销售额为: " + sale + ",佣金为: " + sale * 0.1);
} else if (sale <= 2400) {
System.out.println("现在的" + letter + "数量为: " + arr + ",销售额为: " + sale + ",佣金为: " + (100+(sale-1000) * 0.15));
} else {
System.out.println("现在的" + letter + "数量为: " + arr + ",销售额为: " + sale + ",佣金为: " + (100+1400 * 0.15+(sale-2400) * 0.20));
}
}
}