Reputation: 13
code is not executing the loop properly
specially when the input is 1000 the if loop is not executed properly
program requirement
1) should ask for a sale price for the tickets in dollars (e.g. 15.00)
2)the maximum price for a ticket sale is 999.99
bool cPrice = true;
while (cPrice)
{
cout << "Please enter the event ticket price:";
cin.ignore();
cin >> eventPrice;
cout << "test";
if (eventPrice >= 0 || eventPrice <= 999.99)
{
cPrice = false;
}
else cout << "the valve is invalid.";
}
Upvotes: 0
Views: 26
Reputation: 37023
change your if statement from:
eventPrice >= 0 || eventPrice <= 999.99
To
eventPrice >= 0 && eventPrice <= 999.99
^^
Should be between 0 and 999.99.
Upvotes: 1