0

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.";
    }

1 Answer 1

1

change your if statement from:

eventPrice >= 0 || eventPrice <= 999.99

To

eventPrice >= 0 && eventPrice <= 999.99
                ^^

Should be between 0 and 999.99.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.