#include #include using namespace std; int main() { double weight; while (true) { cout << "Enter your weight: "; cin >> weight; if (cin.fail()) { // We failed to extract a double cin.clear(); // reset stream state to goodbit. cin.ignore(256, '\n'); // remove any input from the stream until \n continue; } if (weight <= 0) continue; break; } cout << "You weight is: " << weight << endl; }