So I dont know what's wrong with my code. I have to do this task for school:
If you are buying more than 5 things, butless than 10 - you get 5% off. If you are buying 10 and more things you get 10% off.
Write a program, which would count how much you need to pay for products.
if(5<k<10){ It is not doing what you think is doing. You need to use one of the logical operators such as && ,||, ! .
Read up on those
The && operator is known as the logical AND operator. It takes two expressions as operands and creates an expression that is true only when both sub-expressions are true. Example:
1 2
if (temperature < 20 && minutes > 12)
cout << "The temperature is in the danger zone.";
The || operator is known as the logical OR operator. It takes two expressions as operands and creates an expression that is true when either of the sub-expressions are true. Example:
1 2
if (temperature < 20 || temperature > 100)
cout << "The temperature is in the danger zone.";
The ! operator performs a logical NOT operation. It takes an operand and reverses its truth or falsehood. In other words, if the expression is true, the ! operator returns false, and if the expression is false, it returns true. Example:
1 2
if (!(temperature > 100))
cout << "You are below the maximum temperature.\n";