Look at what you are doing. I'll shorten it a bit so identical bits are more obvious:

if (a || b || c)
x;
else if ( d || b || c)
y;

That refactors - just to make it more obvious what is happening - to this:

if (a || b || c)
x;
else
if ( d || b || c)
y;

And "||" means "OR" - if either of the conditions on the left or right hand side are true, the whole expression is true.

So if either

`b`

or

`c`

are true, then the whole of the first condition is automatically true. Which means that if either

`b`

or

`c`

is true, the else condition will always be false, and they never contribute to the condition at all: the code in the else block will only get executed is

`d`

is true.

In your case, the only time the

`else if`

expression can be executed is if both

`b`

and

`c`

are false: if

`startcall`

is between 1800 and 800 and that remains true for the second test, so the second test will always be just

`duration < 60`

I'd suggest that you start by reading the question again, and applying the discount in separate tests:

if (right time of day)
{
apply 50% discount;
if (call is long enough)
{
apply extra discount;
}
}

if (duration >60 || startcall >=1800 || startcall < 800) {

discount = (duration * rate /2)*0.15;

grosscost = ((((duration * rate/2)-discount)) * 0.40) + (((duration * rate/2)-discount));

netcost = grosscost;

}

else{if( startcall >=1800 ||startcall <800 ||duration <60){

grosscost = ((duration *rate /2)*0.40) + (duration *rate/2);

netcost = grosscost;

}

}

cout <<"Gross Cost: $ " <<grosscost <<endl;

cout <<"Net cost: $ " <<netcost <<endl;

return 0;

Enter length of call in minutes :40

Gross Cost: $ 9.52

Net cost: $ 9.52

This is what i don't understand. It keeps deducting %15 off despite of being lower than 60.

The result should be $11.20

11.20- 9.52 = 1.68 (which is the %15 when calling over 60 minutes)

thanks for any help

Improve questionto update your question.So that everyone can pay attention to this information.