#include <iostream>
#include <limits>
template <typename T>
T validated_input(std::string error_message)
{
T value;
while(not (std::cin >> value)) { //While input fails
std::cout << error_message; //Output error message
std::cin.clear(); //clear error state
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); //ignore errorneous input
}
return value;
}
int main() {
std::cout << "Enter your weight in pounds to one decimal point: ";
double weight = validated_input<double>("Enter floating point value!\n");
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bGltaXRzPgoKdGVtcGxhdGUgPHR5cGVuYW1lIFQ+ClQgdmFsaWRhdGVkX2lucHV0KHN0ZDo6c3RyaW5nIGVycm9yX21lc3NhZ2UpCnsKICAgIFQgdmFsdWU7CiAgICB3aGlsZShub3QgKHN0ZDo6Y2luID4+IHZhbHVlKSkgeyAvL1doaWxlIGlucHV0IGZhaWxzCiAgICAgICAgc3RkOjpjb3V0IDw8IGVycm9yX21lc3NhZ2U7IC8vT3V0cHV0IGVycm9yIG1lc3NhZ2UKICAgICAgICBzdGQ6OmNpbi5jbGVhcigpOyAvL2NsZWFyIGVycm9yIHN0YXRlCiAgICAgICAgc3RkOjpjaW4uaWdub3JlKHN0ZDo6bnVtZXJpY19saW1pdHM8c3RkOjpzdHJlYW1zaXplPjo6bWF4KCksICdcbicpOyAvL2lnbm9yZSBlcnJvcm5lb3VzIGlucHV0CiAgICB9CiAgICByZXR1cm4gdmFsdWU7Cn0KCgppbnQgbWFpbigpIHsKCXN0ZDo6Y291dCA8PCAiRW50ZXIgeW91ciB3ZWlnaHQgaW4gcG91bmRzIHRvIG9uZSBkZWNpbWFsIHBvaW50OiAiOwoJZG91YmxlIHdlaWdodCA9IHZhbGlkYXRlZF9pbnB1dDxkb3VibGU+KCJFbnRlciBmbG9hdGluZyBwb2ludCB2YWx1ZSFcbiIpOwp9