I just wrote a simple program that calculates markup prices by calling user defined functions I created. That part is done, but I need to make a validation check where the user cannot enter in a negative number. I sorta did that using the if statement, but the program needs to repeat until the user enters a valid number. Any help with this? The way I have it set up, if the user enters a negative number, it just stops.
float x = 0.0; // Initialize as 0.
cout << "Please enter the wholesale cost of an item:" << endl << endl <<"$"; // Move request here
if (x <= 0.0)
cout << "Invalid number. Please enter a positive cost number." << endl << endl;
cout << endl << "The mark up percentage at 100% is: $" << caculateRetail100 (x) << endl << endl;
cout << endl << "The mark up percentage at 50% is: $" << caculateRetail50 (x) << endl << endl;