• + 0 comments

    Java 8

    public static void bonAppetit(List bill, int k, int b) { // Write your code here

        int totalCost = bill.stream().mapToInt(Integer::intValue).sum();
        int splitCharge = (totalCost - bill.get(k)) / 2;
        if(b - splitCharge > 0){
            System.out.println(b - splitCharge);
        } else{
            System.out.println("Bon Appetit");
        }
    
    }