This else if not working

Vy C (10)
Hello all,

I have to convert y and z to a and b. Same with the uppercase values. My code doesn't seem to be working:

1
2
3
4
else if(((value == 'y') &&(value == 'z'))||((value == 'Y')&&(value == 'Z')))
            {
                value -= 24;
}


Am I doing something wrong here.

Thanks
V
Athar (4383)
value can't be both 'y' and 'z' at the same time. The condition is never met.
Vy C (10)
Athar
Could I keep the same condition with changes or would I need to separate the conditions?

Thanks
AbstractionAnon (414)
Just make the operators all ||.
1
2
3
4
else if(value == 'y' || value == 'z' || value == 'Y' || value == 'Z')
            {
                value -= 24;
}

Only works because Y and A and Z and B are the same distance apart. Really not the best way to do this.

Last edited on
Registered users can post here. Sign in or register to post.