怎么修改这个代码,使输入的数只能是1和0,输入其他数就提示错误并要求重新输入,达到下面图片的要求

img

img

 public static void main(String[] args) {
        Scanner you = new Scanner(System.in);
        System.out.print("请输入待检测产品数量:");
        int a = you.nextInt();
        System.out.println("请输入产品质量信息,质量信息用换行(回车)隔开:");
        int[] b;
        b = new int[a];
        int c = 0;
        for (int i = 0; i < a; i++) {
            b[i] = you.nextInt();
            if (b[i] != 1 && b[i] != 0) {
                System.out.println("输入错误请重新输入");
                i--;
            }
            if (b[i] == 1) {
                c++;
            }
        }
        double d = (double) c / a;
        DecimalFormat decimalFormat = new DecimalFormat(".00");
        String e = decimalFormat.format(d * 100);
        System.out.println("本次受检产品合格率为:" + e + "%");
    }