/* Class CD_Collection represents a collection of compact discs, */
/* storing the number of discs and their combined value.         */

class CD_Collection {

   private int num_cds;
   private double value_cds;

   // Creates a CD_Collection object with the specified
   // initial number of CDs and their total value.
   public CD_Collection (int initial_num, double initial_val) {
      num_cds = initial_num;
      value_cds = initial_val;
   }

   // Adds the specified number of CDs to the collection and
   // updates the value.
   public void add_cds (int number, double value) {
      num_cds = num_cds + number;
      value_cds = value_cds + value;
   }

   // Prints a report on the status of the CD collection.
   public void print() {
      System.out.println ("***************");
      System.out.println ("Number of CDs: " + num_cds);
      System.out.println ("Value of collection: $" + value_cds);
      System.out.println ("Average cost per CD: $" + average_cost());
   }

   //  Computes and returns the average cost of a CD in this collection.
   private double average_cost () {
      return value_cds / num_cds;
   }
}  // class CD_Collection

