#include <iostream> using namespace std; class Sensor{ private: int rawValue; int offset; public: // Sensor() : rawValue(0), offset(0) {} // initialize in 1 line Sensor(){ rawValue = 0; offset = 0; } void setRaw(int val){ rawValue = val; } void calibrate(int off){ offset = off; } int read(){ return (rawValue + offset) ; } }; int main() { int raw, offset, newRaw; cin >> raw >> offset >> newRaw; Sensor s; s.setRaw(raw); s.calibrate(offset); s.setRaw(newRaw); cout << s.read(); return 0; }
Test Cases
Test Results
Input
100 -5 120
Expected Output
115