#include <iostream>
#include <string>
#include <cmath>
#include <sstream>   

using namespace std;

class ExcGeneric {
  public:
    virtual string details() = 0;
};

class ExcZero : public ExcGeneric {
  public:
    string details() {     
        return "zero is not allowed here";
    }
};

class ExcNegative : public ExcGeneric {
  public:
    ExcNegative(double value) : 
        value(value) {}
  
    string details() {
        ostringstream stream;
        
        stream << "negative argument: " << this->value;
        
        return stream.str();
    }
    
  private:    
    double value;
};

class ExcOutOfRange : public ExcGeneric {
  public:
    ExcOutOfRange(double value, double min, double max) : 
        value(value), min(min), max(max) {}
    
    string details() {
        ostringstream stream;
        
        stream << "argument: " << this->value << " is out of range [" << min << ", " << max << "]";
        
        return stream.str();
    }
    
  private:    
    double value, min, max;    
};

float safe_div(float x, float y) {
    if (y == 0) 
        throw ExcZero();
        
    return x / y;
}

float safe_sqrt(float x) {
    if (x < 0) 
        throw ExcNegative(x);
        
    return sqrt(x);
}

float safe_range(float x) {
    if (x < 0 || 3 < x) 
        throw ExcOutOfRange(x, 0, 3);
    
    return sqrt(x*(3-x));
}

int main() {
    float x = 4 * atan(1.), y;

    cin >> x;
    cout << "x = " << x << endl;
    cin >> y;
    cout << "y = " << y << endl;
    
    try {
        cout << x << " / " << y << " = " << safe_div(x, y) << endl;
        cout << "sqrt(" << x << ") = " << safe_sqrt(x) << endl;
        cout << "something(" << x << ") = " << safe_range(x) << endl;
        cout << "end of job" << endl;
//    } catch(ExcZero x) {
//        cerr << "exception zero: " << x.details() << endl;
    } catch(ExcGeneric &e) {
        cerr << "exception: " << e.details() << endl;
    }
    
    cout << "good bye" << endl;
}
