//Programmer: Bo Bayles  Date: 19 October 2004
//File: lab9.cpp         Class: CS54 C
//Purpose: This program gets the dimensions of a box from the user to determine
//  surface area, volume, and the difference between the volume of the box's
//  contents to determine how many packing peanuts to use.

#include "box.h"
#include <iostream>
using namespace std;

int main()
{
  int iToyVolume = 0;
  float fBoxVolume = 0, fBoxArea = 0;
  box shippingBox;
  char cContinue = 'y';
  //Declare some variables.

  while ((cContinue != 'n') && (cContinue != 'N'))
  //Gigantic while loop for continuance
  {
    cout << endl << "Toy Packaging Helper" << endl;

    do
    {
      cout << "Enter the toy's volume (cubic inches): ";
      cin >> iToyVolume;

      if (iToyVolume < 0)
        cout << "Invalid entry." << endl;
    }
    while (iToyVolume < 0);
    //Make sure it's positive.

    cout << endl << "Enter the shipping box's dimensions (inches):" << endl;

    do
    {
    //Big do-while loop to make sure the box is big enough.

      do
      {
        cout << "Length: ";
        cin >> shippingBox.length;

        if (shippingBox.length < 0)
	      cout << "Invalid entry." << endl;
      }
      while (shippingBox.length < 0);


      do
      {
        cout << "Width: ";
        cin >> shippingBox.width;

        if (shippingBox.width < 0)
          cout << "Invalid entry." << endl;
      }
      while (shippingBox.width < 0);


      do
      {
        cout << "Height: ";
        cin >> shippingBox.height;

        if (shippingBox.height < 0)
         cout << "Invalid entry." << endl;
      }
      while (shippingBox.height < 0);

      fBoxVolume = boxVolume(shippingBox);

      if (fBoxVolume < iToyVolume)
        cout << "\n Error: Toy is larger than box. Please try again." << endl;
    }
    while (fBoxVolume < iToyVolume);

    fBoxArea = boxSurfaceArea(shippingBox);

    displaySummary(iToyVolume, fBoxVolume, fBoxArea, shippingBox);

    cout << "Package another toy? (y/n): ";
    cin >> cContinue;

  }
  cout << "Exiting..." << endl;

  return 0;
  //Exit normally
}

