Doing a loop having user enter two inputs which will calculate in a function. The program is suppose to continue to run until either a negative number is entered for the price or for the markup. A negative number for price or negative markup will never be sent to the calcRetail function.
My code works up until I enter a negative number for markup. The loop continues. What am I missing so that the loop ends not only when a negative is entered for price but also when a negative number is entered for markup?
double calcRetail(double x = 0.0, double y = 0.0)
{
double retail = x * (1 + (y / 100));
return retail;
}
int main()
{
double price = 0.0, markup = 0.0;
while(price >= 0)
{
cout << "Enter the wholesale price of the item:" << endl;
cin >> price;
if(price >= 0)
{
cout << "Enter the percent markup of the item:" << endl;
cin >> markup;
cout << "$" << calcRetail(price,markup) << endl;
}
}
return 0;
}