Consider the following class definition:public class BadCalc…

Consider the following class definition:public class BadCalculator {        public static int add(int z, int x, int y) {        z = x + y;                    return z;    }    }After executing the following code, what is the final value of z?int z = 100;int x = 13;int y = 21;z = BadCalculator.add(z, x, y);

Suppose that class OrderList has a private attribute double…

Suppose that class OrderList has a private attribute double cost[100] which hold the cost of all ordered items, and a private attributes int num_of_items which hold the number of items ordered. For example, if num_of_items is 5, then cost[0], cost[1], …, cost[4] hold the cost of these 5 items. Implement the member function named average_cost which returns the average cost of this OrderList.