52. Safe Sensor Calibration

 Write a function calibrate that validates a sensor calibration value:

  • void calibrate(int value)
  • If value < 0, throw invalid_argument "Negative not allowed"
  • If value > 1000, throw runtime_error "Out of range"

Otherwise, print:
 Calibrated with <value>
 

The program already reads an integer, calls calibrate, and has multiple catch blocks to handle errors.
You only need to implement the calibrate function.

 

Example
 Input:

200

Output:

Calibrated with 200

 

Input:

-5

Output:

Error: Negative not allowed

 

Input:

5000

Output:

Error: Out of range
Loading...

Input

200

Expected Output

Calibrated with 200