Write a Cart tracking a number of items and a total in cents, both starting at zero. add takes a price and increases both. itemCount and total return them, and averagePrice returns the total divided by the count as a double, or 0.0 for an empty cart.
class Cart { Cart(); void add(int price); int itemCount(); int total(); double averagePrice(); }
Examples
There are also 4 hidden tests you can't see. Solve the problem, not the examples.