//BRYAN WEIR
//1.12
//PS 7
//Problem 1



#define null 0
#include <stdlib.h>
#include <stdio.h>
#include <iostream.h>
#include <math.h>
#include <fstream.h>


class Gauss{

protected:
  double A, B;

public:
  Gauss()
    {}

  Gauss(double uplim, double lowlim)
    {
      A = uplim;
      B = lowlim;
    }

  ~Gauss()
    {}

  void set_limits(double uplim,double lowlim)
    {
      A = uplim;
      B = lowlim;
    }
};

class Sand : public Gauss{

public:
  Sand()
    {}
  ~Sand()
    {}

  double integrand(double x)
    {
      double temp1 = sin(1.27*x);
      temp1 *= temp1*temp1;
      temp1 *=5.0/18.0;
      double temp2 =sin(25*x);
      temp2 *= temp2*temp2;
      temp2 *= 4.0/9.0;
      double temp3 = sin(78.73*x);
      temp3 *=temp3*temp3;
      temp3 *=5.0/18.0;
      return (temp1+temp2+temp3);
    }

  double solver()
    {
    double x1 = .1127016654*B+.8872983345*A;
    double x2 = .5*B+.5*A;
    double x3 = .1127016654*A+.8872983345*B;
    double answer = (B-A)*((5.0/18.0)*integrand(x1)+
		      (4.0/9.0)*integrand(x2)+
		      (5.0/18.0)*integrand(x3));
    return (answer);
  }
};

class Clay : public Gauss{

public:
  Clay()
    {}  
  ~Clay()
    {}

  double integrand(double x)
    {
      double temp0 = cos(0.002*x);
      temp0 *= temp0*temp0*4;
      double temp1 = cos(.56351*x*x*x*x*x);
      temp1 *= temp1*temp1*(5.0/18.0);
      double temp2 = cos(2.5*x*x*x*x*x);
      temp2 *= temp2*temp2*(4.0/9.0);
      double temp3 = cos(4.4365*x*x*x*x*x);
      temp3 *= temp3*temp3*(5.0/18.0);
      return (temp0-700*(temp1+temp2+temp3));
    }
  
  double solver()
    {
      double x1 = .1127016654*B+.8872983345*A;
      double x2 = .5*B+.5*A;
      double x3 = .1127016654*A+.8872983345*B;
      double answer = (B-A)*((5.0/18.0)*integrand(x1)+
			(4.0/9.0)*integrand(x2)+
		      (5.0/18.0)*integrand(x3));
    return (answer);
  }
};


class Fill : public Gauss{

public:
  Fill()
    {}
  ~Fill()
    {}

  double integrand(double x)
    {
      double temp0 = sin(0.01*x);
      temp0 *= temp0*temp0;
      return (temp0-99.5);
    }
  
  double solver()
    {
      double x1 = .1127016654*B+.8872983345*A;
      double x2 = .5*B+.5*A;
      double x3 = .1127016654*A+.8872983345*B;
      double answer = (B-A)*((5.0/18.0)*integrand(x1)+
			  (4.0/9.0)*integrand(x2)+
			  (5.0/18.0)*integrand(x3));
      return (answer);
    }
};

  
int main()
{
  double vol_sand, vol_clay, vol_fill;
  
  Sand S;
  S.set_limits(0,900);
  
  vol_sand = 2500.0*S.solver()+(500.0*950.0*20);
  cout << "The Volume of Sand is: " << vol_sand << endl;
  
  Clay C;
  C.set_limits(0,900);
  vol_clay = C.solver()+(500.0*950.0*30);
  vol_clay -= vol_sand;
  cout << "The Volume of Clay is: " << vol_clay << endl;

  Fill F;
  F.set_limits(0, 900);
  vol_fill = F.solver()+(500.0*950.0*50);
  vol_fill -= (vol_sand+vol_clay);
  cout << "The Volume of Fill is: " << vol_fill << endl;
}


    


































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































