Variable may be uninitialized/is used uninitialized
Variable may be uninitialized/is used uninitialized I'm writing an English-Metric converter program in C++, and I'm trying to use try, throw, catch to reject negative/non-numeric values in the 'main' function. My two problems are: 1.) Whenever I enter, say, 'g' into the console, I get an output: 0 inches is equal to 0 centimeters AND THEN I get the error display that I want to pop up. What i need is only the error display to be output. 2.) When I enter a negative number, like -3, I get the proper conversion as a negative number when I would like it to tell me my input is invalid. Here is my code. #include <iostream> #include <cctype> char menuSelect(); using namespace std; int main(int argc, const char * argv) { double inches; double centimeters; char select; try { do { if (centimeters < 0.0 || inches < 0.0) throw 0; if (!cin) throw 0; select...