'How would I write this if statement

The condition is that a product gets a discount if it is bought on september 15th through october 15th. How would I write an if statement for this?

You could start off with:

if ((month != 9 || month != 10) && (day....



Solution 1:[1]

I would say:

if (month == 9 && day >= 15) || (month == 10 && day <=15)

Solution 2:[2]

if((month == 9 && day >= 15) || (month == 10 && day <= 15)) { }

Solution 3:[3]

if ((month == 9 && day >= 15) || (month == 10 && day <= 15))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Eric
Solution 2 Özgür Güzeldereli
Solution 3